Mercurial > hg > octave-lojdl
changeset 14003:1555c5a177c9
better fix for fontconfig segfault
* txt-eng-ft.cc (ft_manager::fontconfig_initialized): Rename from
fc_init_done. Always declare and define.
(ft_manager::freetype_initialized): New data member.
(ft_manager::ft_manager): Set freetype_initialized.
(ft_manager::~ft_manager): Call FT_Done_FreeType if freetype is
initialized. Comment out code to conditionally call FcFini.
(ft_manager::instance_ok): Do delete instance.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 07 Dec 2011 04:16:27 -0500 |
parents | 82f5f76726a2 |
children | 92e45016eb48 |
files | src/txt-eng-ft.cc |
diffstat | 1 files changed, 26 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/txt-eng-ft.cc +++ b/src/txt-eng-ft.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#if HAVE_FREETYPE +#if defined (HAVE_FREETYPE) -#if HAVE_FONTCONFIG +#if defined (HAVE_FONTCONFIG) #include <fontconfig/fontconfig.h> #endif @@ -77,14 +77,8 @@ { instance = new ft_manager (); - // FIXME -- there seem to be some memory management errors - // related to fontconfig that cause segfaults when Octave - // exits if ft_manager::instance is explicitly deleted. So - // skip doing that for now. -#if 0 if (instance) singleton_cleanup_list::add (cleanup_instance); -#endif } if (! instance) @@ -117,37 +111,39 @@ ft_manager& operator = (const ft_manager&); - ft_manager (void) : library () -#if HAVE_FONTCONFIG - , fc_init_done (false) -#endif + ft_manager (void) + : library (), freetype_initialized (false), fontconfig_initialized (false) { if (FT_Init_FreeType (&library)) - { - ::error ("unable to initialize freetype library"); - } + ::error ("unable to initialize freetype library"); + else + freetype_initialized = true; -#if HAVE_FONTCONFIG - fc_init_done = false; +#if defined (HAVE_FONTCONFIG) if (! FcInit ()) - { - ::error ("unable to initialize fontconfig library"); - } + ::error ("unable to initialize fontconfig library"); else - { - fc_init_done = true; - } + fontconfig_initialized = true; #endif } ~ft_manager (void) { -#if HAVE_FONTCONFIG - FcFini (); - fc_init_done = false; + if (freetype_initialized) + FT_Done_FreeType (library); + +#if defined (HAVE_FONTCONFIG) + // FIXME -- Skip the call to FcFini because it can trigger the + // assertion + // + // octave: fccache.c:507: FcCacheFini: Assertion `fcCacheChains[i] == ((void *)0)' failed. + // + // if (fontconfig_initialized) + // FcFini (); #endif } + FT_Face do_get_font (const std::string& name, const std::string& weight, const std::string& angle, double size) { @@ -155,8 +151,8 @@ std::string file; -#if HAVE_FONTCONFIG - if (fc_init_done) +#if defined (HAVE_FONTCONFIG) + if (fontconfig_initialized) { int fc_weight, fc_angle; @@ -233,9 +229,8 @@ private: FT_Library library; -#if HAVE_FONTCONFIG - bool fc_init_done; -#endif + bool freetype_initialized; + bool fontconfig_initialized; }; ft_manager* ft_manager::instance = 0;