Fix bug when shutting down all engine and still have some font in the cache.

Draw back: When we are destroying an Evas canvas, we loose all cached font
that are not used anymore.

A correct fix would be to link Fndat to the Evas that provide and use them.
And only delete them when no more Evas reference them.


SVN revision: 37353
This commit is contained in:
Cedric BAIL 2008-10-31 10:46:46 +00:00
parent 8e06d6fbea
commit cdf08d5696
5 changed files with 26 additions and 8 deletions

View File

@ -95,6 +95,24 @@ evas_font_set_get(const char *name)
return fonts;
}
void
evas_fonts_zero_free(Evas *evas)
{
Fndat *fd;
while (fonts_zero)
{
fd = eina_list_data_get(fonts_zero);
if (fd->name) eina_stringshare_del(fd->name);
if (fd->source) eina_stringshare_del(fd->source);
evas->engine.func->font_free(evas->engine.data.output, fd->font);
free(fd);
fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero);
}
}
void
evas_font_free(Evas *evas, void *font)
{
@ -117,8 +135,6 @@ evas_font_free(Evas *evas, void *font)
while ((fonts_zero) &&
(eina_list_count(fonts_zero) > 4)) /* 4 is arbitrary */
{
Fndat *fd;
fd = eina_list_data_get(fonts_zero);
if (fd->ref != 0) break;
fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero);
@ -177,7 +193,7 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
fonts = evas_font_set_get(name);
EINA_LIST_FOREACH(fonts, l, nm) /* Load each font in append */
{
if ((l == fonts) || (!font)) /* First iteration OR no font */
if (l == fonts || !font) /* First iteration OR no font */
{
#ifdef BUILD_FONT_LOADER_EET
if (source) /* Load Font from "eet" source */
@ -301,10 +317,9 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
}
eina_stringshare_del(nm);
}
eina_list_free(fonts);
fonts = eina_list_free(fonts);
#ifdef HAVE_FONTCONFIG
if (!font) /* Search using fontconfig */
{
FcPattern *p_nm = NULL;

View File

@ -154,7 +154,9 @@ evas_free(Evas *e)
e->obscures = eina_list_remove(e->obscures, e->obscures->data);
}
if (e->engine.func)
evas_fonts_zero_free(e);
if (e->engine.func)
{
e->engine.func->info_free(e, e->engine.info);
e->engine.func->context_free(e->engine.data.output, e->engine.data.context);

View File

@ -768,6 +768,7 @@ const char *evas_font_dir_cache_find(char *dir, char *font);
Eina_List *evas_font_dir_available_list(const Evas* evas);
void evas_font_dir_available_list_free(Eina_List *available);
void evas_font_free(Evas *evas, void *font);
void evas_fonts_zero_free(Evas *evas);
void *evas_font_load(Evas *evas, const char *name, const char *source, int size);
void evas_font_load_hinting_set(Evas *evas, void *font, int hinting);
void evas_object_smart_member_cache_invalidate(Evas_Object *obj);

View File

@ -225,7 +225,7 @@ evas_engine_sdl16_output_free(void *data)
if (re->soft16_engine_image) evas_cache_engine_image_drop(&re->soft16_engine_image->cache_entry);
free(re);
/* evas_common_font_shutdown(); */
evas_common_font_shutdown();
evas_common_image_shutdown();
evas_common_soft16_image_shutdown();
}

View File

@ -133,7 +133,7 @@ evas_engine_sdl_output_free (void *data)
free(re->update_rects);
free(re);
/* evas_common_font_shutdown(); */
evas_common_font_shutdown();
evas_common_image_shutdown();
SDL_QuitSubSystem(SDL_INIT_VIDEO);