From 3f5dba1eb77f18c976888ecfc502bf56c617201f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 6 Jan 2009 09:52:00 +0000 Subject: [PATCH] =?utf8?q?Bug=20166676=20=E2=80=93=20pango=5Ffc=5Ffont=5Fm?= =?utf8?q?ap=5Ffinalize?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2009-01-06 Behdad Esfahbod Bug 166676 – pango_fc_font_map_finalize * pango/pangofc-fontmap.c (pango_fc_font_map_finalize), (pango_fc_face_describe), (pango_fc_face_list_sizes), (pango_fc_face_finalize), (pango_fc_face_class_init), (pango_fc_family_list_faces), (pango_fc_family_finalize), (pango_fc_family_class_init): Finalize families and faces. svn path=/trunk/; revision=2784 --- ChangeLog | 11 ++++++++ pango/pangofc-fontmap.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59dc380..e1518f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-01-06 Behdad Esfahbod + + Bug 166676 – pango_fc_font_map_finalize + + * pango/pangofc-fontmap.c (pango_fc_font_map_finalize), + (pango_fc_face_describe), (pango_fc_face_list_sizes), + (pango_fc_face_finalize), (pango_fc_face_class_init), + (pango_fc_family_list_faces), (pango_fc_family_finalize), + (pango_fc_family_class_init): + Finalize families and faces. + 2009-01-06 Tor Lillqvist Bug 164001 - pango-querymodules doesn't work uninstalled on win32 diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 15ca8f0..9339f32 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -483,7 +483,7 @@ pango_fc_font_map_finalize (GObject *object) { PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (object); PangoFcFontMapPrivate *priv = fcfontmap->priv; - + int i; /* Shutdown, so we clear the fonts and mark them as shut down */ pango_fc_font_map_shutdown (fcfontmap); @@ -505,6 +505,13 @@ pango_fc_font_map_finalize (GObject *object) priv->findfuncs = g_slist_delete_link (priv->findfuncs, priv->findfuncs); } + for (i = 0; i < priv->n_families; i++) + { + priv->families[i]->fontmap = NULL; + g_object_unref (priv->families[i]); + } + g_free (priv->families); + G_OBJECT_CLASS (pango_fc_font_map_parent_class)->finalize (object); } @@ -1642,6 +1649,8 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz * PangoFcFace */ +static GObjectClass *pango_fc_face_parent_class = NULL; + static PangoFontDescription * make_alias_description (PangoFcFamily *fcfamily, gboolean bold, @@ -1666,6 +1675,8 @@ pango_fc_face_describe (PangoFontFace *face) FcPattern *match_pattern; FcPattern *result_pattern; + g_return_val_if_fail (fcfamily != NULL, NULL); + if (fcface->fake) { if (strcmp (fcface->style, "Regular") == 0) @@ -1733,6 +1744,11 @@ pango_fc_face_list_sizes (PangoFontFace *face, FcFontSet *fontset; FcObjectSet *objectset; + *sizes = NULL; + *n_sizes = 0; + g_return_if_fail (fcface->family != NULL); + g_return_if_fail (fcface->family->fontmap != NULL); + pattern = FcPatternCreate (); FcPatternAddString (pattern, FC_FAMILY, (FcChar8*)(void*)fcface->family->family_name); FcPatternAddString (pattern, FC_STYLE, (FcChar8*)(void*)fcface->style); @@ -1805,8 +1821,23 @@ pango_fc_face_is_synthesized (PangoFontFace *face) } static void +pango_fc_face_finalize (GObject *object) +{ + PangoFcFace *fcface = PANGO_FC_FACE (object); + + g_free (fcface->style); + + pango_fc_face_parent_class->finalize (object); +} + +static void pango_fc_face_class_init (PangoFontFaceClass *class) { + GObjectClass *object_class = G_OBJECT_CLASS (class); + + pango_fc_face_parent_class = g_type_class_peek_parent (class); + object_class->finalize = pango_fc_face_finalize; + class->describe = pango_fc_face_describe; class->get_face_name = pango_fc_face_get_face_name; class->list_sizes = pango_fc_face_list_sizes; @@ -1845,6 +1876,9 @@ pango_fc_face_get_type (void) /* * PangoFcFamily */ + +static GObjectClass *pango_fc_family_parent_class = NULL; + static PangoFcFace * create_face (PangoFcFamily *fcfamily, const char *style, @@ -1865,7 +1899,13 @@ pango_fc_family_list_faces (PangoFontFamily *family, { PangoFcFamily *fcfamily = PANGO_FC_FAMILY (family); PangoFcFontMap *fcfontmap = fcfamily->fontmap; - PangoFcFontMapPrivate *priv = fcfontmap->priv; + PangoFcFontMapPrivate *priv; + + *faces = NULL; + *n_faces = 0; + g_return_if_fail (fcfontmap != NULL); + + priv = fcfontmap->priv; if (fcfamily->n_faces < 0) { @@ -2003,8 +2043,31 @@ pango_fc_family_is_monospace (PangoFontFamily *family) } static void +pango_fc_family_finalize (GObject *object) +{ + int i; + PangoFcFamily *fcfamily = PANGO_FC_FAMILY (object); + + g_free (fcfamily->family_name); + + for (i = 0; i < fcfamily->n_faces; i++) + { + fcfamily->faces[i]->family = NULL; + g_object_unref (fcfamily->faces[i]); + } + g_free (fcfamily->faces); + + pango_fc_family_parent_class->finalize (object); +} + +static void pango_fc_family_class_init (PangoFontFamilyClass *class) { + GObjectClass *object_class = G_OBJECT_CLASS (class); + + pango_fc_family_parent_class = g_type_class_peek_parent (class); + object_class->finalize = pango_fc_family_finalize; + class->list_faces = pango_fc_family_list_faces; class->get_name = pango_fc_family_get_name; class->is_monospace = pango_fc_family_is_monospace; -- 2.7.4