[pango] Port PangoWin32 to use GWeakRef
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] Port PangoWin32 to use GWeakRef
- Date: Fri, 15 Mar 2013 10:25:50 +0000 (UTC)
commit 16e4dd37e5fdd231a32bba6a1238ff01408c783d
Author: Behdad Esfahbod <behdad behdad org>
Date: Fri Mar 15 05:57:52 2013 -0400
Port PangoWin32 to use GWeakRef
Patch from Chun-wei Fan.
pango/pangowin32-fontmap.c | 8 ++++----
pango/pangowin32.c | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 460afb2..eb54e61 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 8678ebb..bb5b975 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]