From ddd26290bb7a72e217965ccd893c1fc417f426a0 Mon Sep 17 00:00:00 2001 From: cedric Date: Fri, 31 Oct 2008 10:46:46 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@37353 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/canvas/evas_font_dir.c | 25 ++++++++++++++++++----- src/lib/canvas/evas_main.c | 4 +++- src/lib/include/evas_private.h | 1 + src/modules/engines/software_16_sdl/evas_engine.c | 2 +- src/modules/engines/software_sdl/evas_engine.c | 2 +- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/lib/canvas/evas_font_dir.c b/src/lib/canvas/evas_font_dir.c index f3175f6..b8c84c3 100644 --- a/src/lib/canvas/evas_font_dir.c +++ b/src/lib/canvas/evas_font_dir.c @@ -96,6 +96,24 @@ evas_font_set_get(const char *name) } 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) { Eina_List *l; @@ -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; diff --git a/src/lib/canvas/evas_main.c b/src/lib/canvas/evas_main.c index 2893236..0e9d747 100644 --- a/src/lib/canvas/evas_main.c +++ b/src/lib/canvas/evas_main.c @@ -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); diff --git a/src/lib/include/evas_private.h b/src/lib/include/evas_private.h index 5a5302d..0c322a2 100644 --- a/src/lib/include/evas_private.h +++ b/src/lib/include/evas_private.h @@ -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); diff --git a/src/modules/engines/software_16_sdl/evas_engine.c b/src/modules/engines/software_16_sdl/evas_engine.c index a215a09..b6e03f5 100644 --- a/src/modules/engines/software_16_sdl/evas_engine.c +++ b/src/modules/engines/software_16_sdl/evas_engine.c @@ -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(); } diff --git a/src/modules/engines/software_sdl/evas_engine.c b/src/modules/engines/software_sdl/evas_engine.c index bed58e3..aa4712d 100644 --- a/src/modules/engines/software_sdl/evas_engine.c +++ b/src/modules/engines/software_sdl/evas_engine.c @@ -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); -- 2.7.4