summaryrefslogtreecommitdiff
path: root/pango/fonts.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2008-08-22 07:01:35 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2008-08-22 07:01:35 +0000
commitd8b4b188b676b9cdb3f33a599fc2a77051c6938c (patch)
tree2de7ef235a30da00f5025d1a4c3d2e12966f0c37 /pango/fonts.c
parent10405497c1479fd0366458c76e5036ae5e947abb (diff)
downloadpango-d8b4b188b676b9cdb3f33a599fc2a77051c6938c.tar.gz
Bug 143542 – PangoFT2Fontmap leak
2008-08-22 Behdad Esfahbod <behdad@gnome.org> Bug 143542 – PangoFT2Fontmap leak * pango/fonts.c: * pango/pangoatsui.c (pango_atsui_font_finalize), (_pango_atsui_font_set_font_map): * pango/pangocairo-font.c (_pango_cairo_font_get_metrics), (_pango_cairo_font_private_get_hex_box_info): * pango/pangocairo-win32font.c (_pango_cairo_win32_font_new): * pango/pangofc-font.c (pango_fc_font_get_metrics): * pango/pangofc-fontmap.c (pango_fc_font_map_add), (_pango_fc_font_map_remove), (cleanup_font): * pango/pangowin32-fontmap.c (pango_win32_font_neww), (pango_win32_font_map_real_find_font): * pango/pangowin32.c (pango_win32_font_finalize): * pango/pangox-fontmap.c (pango_x_font_map_load_font): * pango/pangox.c (pango_x_font_new), (pango_x_font_finalize): Make the reference the font->fontmap reference weak. The code for setting the reference must look like this: g_assert (font->fontmap == NULL); font->fontmap = (PangoFontMap *) fontmap; g_object_add_weak_pointer (G_OBJECT (font->fontmap), (gpointer *) (gpointer) &font->fontmap); And releasing it like: g_assert (font->fontmap != NULL); g_object_remove_weak_pointer (G_OBJECT (font->fontmap), (gpointer *) (gpointer) &font->fontmap); font->fontmap = NULL; I have converted all fontmaps. The win32 and atsui ones can use some simple testing. The PangoFc fonts actually don't need the weakref as the fontmap already provides a similar link by itself. svn path=/trunk/; revision=2704
Diffstat (limited to 'pango/fonts.c')
-rw-r--r--pango/fonts.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index efb989bb..2f997035 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1414,10 +1414,18 @@ pango_font_get_metrics (PangoFont *font,
/**
* pango_font_get_font_map:
- * @font: a #PangoFont
+ * @font: a #PangoFont, or %NULL
*
* Gets the font map for which the font was created.
*
+ * Note that the font maintains a <firstterm>weak</firstterm> reference
+ * to the font map, so if all references to font map are dropped, the font
+ * map will be finalized even if there are fonts created with the font
+ * map that are still alive. In that case this function will return %NULL.
+ * It is the responsibility of the user to ensure that the font map is kept
+ * alive. In most uses this is not an issue as a #PangoContext holds
+ * a reference to the font map.
+ *
* Return value: the #PangoFontMap for the font, or %NULL if @font is %NULL.
*
* Since: 1.10