From 29dd8e2b47f82171942dc6808901e2b503910513 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 4 Feb 2013 15:37:41 +0000 Subject: [PATCH] evas: Stop initializing and shutting Fontconfig down A few days ago I was investigating a bug in the EFL WebKit port and noticed WebKit's and Evas' handling of Fontconfig are somewhat incompatible: while the evas_font code calls both FcInit() and FcFini() when on initialization and shutdown, respectively, WebKit keeps some Fontconfig objects alive until the process exits. In practice, this means that shutting Evas down will cause FcFini() to assert because there are objects which have not been properly destroyed. This is not really a WebKit-specific problem, as any program which also uses Fontconfig directly and shuts Evas down before destroying all FC resources it has allocated is going to crash in the same way. Other libraries such as Qt, Pango and Cairo do not explicitly initialize and shut Fontconfig down. Evas itself got this code in r40242 and was later adjusted in r45829 and r74870. Since we can't completely control the lifetime of all Fontconfig objects used in client code, I was thinking of doing the same thing as other libraries do and get rid of the calls to FcInit() and FcFini(). The part which is really important is not calling FcFini() -- this was already done for a while in the r45829 which I mentioned. Valgrind will complain about some "still reachable" memory blocks, but that's not really important (as raster said in that revision's commit message, "things may look like they leak in Valgrind - they dont. in reality"). Note: tasn tried to talk about it with fc guys and it's the way to go. They won't implemented refcount as suggested in our ml. Patch by: Raphael Kubo da Costa SVN revision: 83605 --- src/lib/evas/canvas/evas_font_dir.c | 41 ------------------------------------- 1 file changed, 41 deletions(-) diff --git a/src/lib/evas/canvas/evas_font_dir.c b/src/lib/evas/canvas/evas_font_dir.c index ecf2233..7433154 100644 --- a/src/lib/evas/canvas/evas_font_dir.c +++ b/src/lib/evas/canvas/evas_font_dir.c @@ -48,10 +48,6 @@ static Evas_Font_Dir *object_text_font_cache_dir_add(char *dir); static void object_text_font_cache_dir_del(char *dir, Evas_Font_Dir *fd); static int evas_object_text_font_string_parse(char *buffer, char dest[14][256]); -#ifdef HAVE_FONTCONFIG -static int fc_init = 0; -#endif - void evas_font_dir_cache_free(void) { @@ -61,23 +57,6 @@ evas_font_dir_cache_free(void) eina_hash_free(font_dirs); font_dirs = NULL; } - -#ifdef HAVE_FONTCONFIG - if (fc_init > 0) - { - fc_init--; -/* this is bad i got a: - * fccache.c:512: FcCacheFini: Assertion fcCacheChains[i] == ((void *)0)' failed. - * - * all i can do for now is shut this puppy down. butthat breaks, so disable - * it as in reality - there is little reason to care about the memory not - * being freed etc. - * - * note 04/08/2012 - this doesnt seem to cause an issue anymore? - */ - if (fc_init == 0) FcFini(); - } -#endif } const char * @@ -219,22 +198,6 @@ evas_font_free(Evas *eo_evas, void *font) } } -static void -evas_font_init(void) -{ - static int done = 0; - if (done) return; - done = 1; -#ifdef HAVE_FONTCONFIG - fc_init++; - if (fc_init == 1) - { - FcInit(); - FcConfigEnableHome(1); - } -#endif -} - #ifdef HAVE_FONTCONFIG static Evas_Font_Set * evas_load_fontconfig(Evas *eo_evas, FcFontSet *set, int size, @@ -519,8 +482,6 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, if (fdesc->weight == EVAS_FONT_WEIGHT_BOLD) wanted_rend |= FONT_REND_WEIGHT; - evas_font_init(); - EINA_LIST_FOREACH(fonts_cache, l, fd) { if (!evas_font_desc_cmp(fdesc, fd->fdesc)) @@ -814,8 +775,6 @@ evas_font_dir_available_list(const Evas *eo_evas) FcObjectSet *os; int i; - evas_font_init(); - p = FcPatternCreate(); os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, NULL); -- 2.7.4