b=454730 Move shutdown of GTK's fontmap from gfxPlatformGtk to nsAppRunner r=roc sr=bsmedberg

This commit is contained in:
Karl Tomlinson 2008-09-26 10:38:25 +12:00
parent 1c1ad46be7
commit a1f89017f4
9 changed files with 47 additions and 33 deletions

View File

@ -523,8 +523,6 @@ MOZ_GTHREAD_LIBS = @MOZ_GTHREAD_LIBS@
FT2_CFLAGS = @FT2_CFLAGS@
FT2_LIBS = @FT2_LIBS@
MOZ_XFT_CFLAGS = @MOZ_XFT_CFLAGS@
MOZ_XFT_LIBS = @MOZ_XFT_LIBS@
MOZ_PANGO_CFLAGS = @MOZ_PANGO_CFLAGS@
MOZ_PANGO_LIBS = @MOZ_PANGO_LIBS@

View File

@ -82,7 +82,6 @@ STATIC_EXTRA_LIBS += $(MOZ_CAIRO_LIBS)
ifdef MOZ_ENABLE_GTK2
STATIC_EXTRA_LIBS += $(XLDFLAGS) $(XT_LIBS) -lgthread-2.0
STATIC_EXTRA_LIBS += $(MOZ_XFT_LIBS)
STATIC_EXTRA_LIBS += $(MOZ_PANGO_LIBS)
endif

View File

@ -5004,23 +5004,17 @@ MOZ_ARG_DISABLE_BOOL(pango,
dnl ========================================================
dnl = Xft and Pango
dnl = Pango
dnl ========================================================
if test "$MOZ_ENABLE_GTK2"
then
if test "$MOZ_X11"; then
PKG_CHECK_MODULES(MOZ_XFT, xft)
AC_SUBST(MOZ_XFT_CFLAGS)
AC_SUBST(MOZ_XFT_LIBS)
fi
AC_SUBST(MOZ_PANGO)
PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
if test "$MOZ_PANGO"
then
PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangocairo >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION)
PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION)
AC_SUBST(MOZ_PANGO_CFLAGS)
AC_SUBST(MOZ_PANGO_LIBS)
AC_DEFINE(MOZ_PANGO)

View File

@ -105,7 +105,7 @@ ifdef MOZ_DFB
CSRCS = cairo-gdk-utils.c
endif
EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS) $(ZLIB_LIBS) $(MOZ_XFT_LIBS) $(XLDFLAGS) $(XLIBS)
EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS) $(ZLIB_LIBS) $(XLDFLAGS) $(XLIBS)
endif
ifdef MOZ_DFB
@ -119,7 +119,7 @@ CPPSRCS += gfxFT2Fonts.cpp
CPPSRCS += gfxFontconfigUtils.cpp
CPPSRCS += nsUnicodeRange.cpp
#CSRCS = cairo-xlib-utils.c
EXTRA_DSO_LDOPTS += $(ZLIB_LIBS) $(MOZ_XFT_LIBS) $(XLDFLAGS) $(XLIBS) $(CAIRO_FT_LIBS)
EXTRA_DSO_LDOPTS += $(ZLIB_LIBS) $(XLDFLAGS) $(XLIBS) $(CAIRO_FT_LIBS)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
@ -128,7 +128,7 @@ CPPSRCS += gfxPangoFonts.cpp
#CPPSRCS += gfxPDFSurface.cpp
CPPSRCS += gfxFontconfigUtils.cpp
CPPSRCS += nsUnicodeRange.cpp
EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS) $(CAIRO_FT_LIBS) -lfontconfig -lpangocairo-1.0
EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS) $(CAIRO_FT_LIBS) -lfontconfig
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)

View File

@ -608,15 +608,6 @@ gfxPangoFont::~gfxPangoFont()
gfxPangoFont::Shutdown()
{
gfxPangoFontCache::Shutdown();
// This just cleans up memory used by Pango's caches and may cause an
// assert and crash in cairo (Bug 399556), so only do this when we care
// about cleaning up memory on shutdown.
#if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) || defined(NS_TRACE_MALLOC)
PangoFontMap *fontmap = pango_cairo_font_map_get_default ();
if (PANGO_IS_FC_FONT_MAP (fontmap))
pango_fc_font_map_shutdown (PANGO_FC_FONT_MAP (fontmap));
#endif
}
static PangoStyle

View File

@ -97,7 +97,7 @@ OS_LIBS += -framework Cocoa
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
OS_LIBS += $(MOZ_PANGO_LIBS) $(MOZ_XFT_LIBS) $(XLIBS)
OS_LIBS += $(MOZ_PANGO_LIBS) $(XLIBS)
CXXFLAGS += $(MOZ_PANGO_CFLAGS)
endif

View File

@ -228,12 +228,12 @@ EXTRA_DSO_LDOPTS += $(MOZ_DBUS_GLIB_LIBS)
endif
ifeq (gtk2,$(MOZ_WIDGET_TOOLKIT))
EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(MOZ_XFT_LIBS) $(MOZ_GTK2_LIBS) $(XT_LIBS) -lgthread-2.0
EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(MOZ_PANGO_LIBS) $(MOZ_GTK2_LIBS) $(XT_LIBS) -lgthread-2.0
EXTRA_DSO_LDOPTS += $(FT2_LIBS)
endif
ifeq (qt,$(MOZ_WIDGET_TOOLKIT))
EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(MOZ_XFT_LIBS) $(XT_LIBS) $(MOZ_QT_LIBS) -lgthread-2.0
EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(XT_LIBS) $(MOZ_QT_LIBS) -lgthread-2.0
EXTRA_DSO_LDOPTS += $(FT2_LIBS)
endif

View File

@ -86,10 +86,6 @@ EXTRA_DSO_LDOPTS += -lmozglitzagl -framework OpenGL -framework AGL
endif
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS)
endif
export:: dlldeps.cpp
dlldeps.cpp: $(topsrcdir)/xpcom/build/dlldeps.cpp

View File

@ -273,6 +273,12 @@ static int gRestartArgc;
static char **gRestartArgv;
#if defined(MOZ_WIDGET_GTK2)
#if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) \
|| defined(NS_TRACE_MALLOC)
#define CLEANUP_MEMORY 1
#define PANGO_ENABLE_BACKEND
#include <pango/pangofc-fontmap.h>
#endif
#include <gtk/gtk.h>
#ifdef MOZ_X11
#include <gdk/gdkx.h>
@ -2424,12 +2430,42 @@ static void MOZ_gdk_display_close(GdkDisplay *display)
#endif /* MOZ_X11 */
}
else {
#if CLEANUP_MEMORY
// Get a (new) Pango context that holds a reference to the fontmap that
// GTK has been using. gdk_pango_context_get() must be called while GTK
// has a default display.
PangoContext *pangoContext = gdk_pango_context_get();
#endif
if (!theme_is_qt)
gdk_display_close(display);
#if GTK_CHECK_VERSION(2,8,0) && \
(defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) || defined(NS_TRACE_MALLOC))
cairo_debug_reset_static_data();
#if CLEANUP_MEMORY
// This doesn't take a reference.
PangoFontMap *fontmap = pango_context_get_font_map(pangoContext);
// Do some shutdown of the fontmap, which releases the fonts, clearing a
// bunch of circular references from the fontmap through the fonts back to
// itself. The shutdown that this does is much less than what's done by
// the fontmap's finalize, though.
if (PANGO_IS_FC_FONT_MAP(fontmap))
pango_fc_font_map_shutdown(PANGO_FC_FONT_MAP(fontmap));
g_object_unref(pangoContext);
// PangoCairo still holds a reference to the fontmap.
// Now that we have finished with GTK and Pango, we could unref fontmap,
// which would allow us to call FcFini, but removing what is really
// Pango's ref feels a bit evil. Pango-1.22 will have support for
// pango_cairo_font_map_set_default(NULL), which would release the
// reference on the old fontmap.
#if GTK_CHECK_VERSION(2,8,0)
// cairo_debug_reset_static_data() is prototyped through cairo.h included
// by gtk.h.
#ifdef cairo_debug_reset_static_data
#error "Looks like we're including Mozilla's cairo instead of system cairo"
#endif
cairo_debug_reset_static_data();
#endif // 2.8.0
#endif // CLEANUP_MEMORY
}
}
#endif // MOZ_WIDGET_GTK2