diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2013-03-15 05:57:52 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2013-03-15 06:25:33 -0400 |
commit | 16e4dd37e5fdd231a32bba6a1238ff01408c783d (patch) | |
tree | b8e1079d711ab4cc55d48942443430be677e35cf /pango | |
parent | e95a0ecd5d1bbcc0c96fc52160edc18292f66f04 (diff) | |
download | pango-16e4dd37e5fdd231a32bba6a1238ff01408c783d.tar.gz |
Port PangoWin32 to use GWeakRef
Patch from Chun-wei Fan.
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pangowin32-fontmap.c | 8 | ||||
-rw-r--r-- | pango/pangowin32.c | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c index 460afb21..eb54e61d 100644 --- a/pango/pangowin32-fontmap.c +++ b/pango/pangowin32-fontmap.c @@ -678,7 +678,7 @@ pango_win32_font_map_fontset_add_fonts (PangoFontMap *fontmap, /* Mostly use the "old" pango_font_map_fontset_add_fonts() */ /* on Windows so that we can go through the .aliases file */ /* to load the appropriate fontset for various texts */ - PangoFont *font, *result; + PangoFont *font; char **aliases; int n_aliases; int j; @@ -989,9 +989,9 @@ pango_win32_font_neww (PangoFontMap *fontmap, result = (PangoWin32Font *)g_object_new (PANGO_TYPE_WIN32_FONT, NULL); - g_assert (result->fontmap == NULL); - result->fontmap = fontmap; - g_object_add_weak_pointer (G_OBJECT (result->fontmap), (gpointer *) (gpointer) &result->fontmap); + if (G_UNLIKELY(result->fontmap)) + return result; + g_weak_ref_set ((GWeakRef *)&result->fontmap, fontmap); result->size = size; _pango_win32_make_matching_logfontw (fontmap, lfp, size, &result->logfontw); diff --git a/pango/pangowin32.c b/pango/pangowin32.c index 8678ebbc..bb5b9751 100644 --- a/pango/pangowin32.c +++ b/pango/pangowin32.c @@ -818,8 +818,10 @@ pango_win32_font_finalize (GObject *object) { PangoWin32Font *win32font = (PangoWin32Font *)object; PangoWin32FontCache *cache = pango_win32_font_map_get_font_cache (win32font->fontmap); + PangoWin32Font *fontmap; + if (G_UNLIKELY (!cache)) - return NULL; + return; if (win32font->hfont != NULL) pango_win32_font_cache_unload (cache, win32font->hfont); @@ -832,11 +834,9 @@ pango_win32_font_finalize (GObject *object) g_hash_table_destroy (win32font->glyph_info); - if (win32font->fontmap) - { - g_object_remove_weak_pointer (G_OBJECT (win32font->fontmap), (gpointer *) (gpointer) &win32font->fontmap); - win32font->fontmap = NULL; - } + fontmap = g_weak_ref_get ((GWeakRef *) &win32font->fontmap); + if (fontmap) + g_object_unref (fontmap); G_OBJECT_CLASS (_pango_win32_font_parent_class)->finalize (object); } |