[pango] [win32] Fix assertion and warnings
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] [win32] Fix assertion and warnings
- Date: Tue, 26 Feb 2013 04:38:02 +0000 (UTC)
commit 0654dfb2ddc66fe70cd5582ccc0ec08ba8154ac6
Author: Behdad Esfahbod <behdad behdad org>
Date: Mon Feb 25 23:37:16 2013 -0500
[win32] Fix assertion and warnings
When win32 fontmap goes away, font->fontmap becomes NULL. Deal
with that. Technically speaking, we need to port this to GWeakRef
like the other fontmaps do. But this would do for now.
pango/pangowin32-fontmap.c | 4 +++-
pango/pangowin32.c | 12 +++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 5dc2a82..460afb2 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -1701,7 +1701,9 @@ pango_win32_face_get_type (void)
PangoWin32FontCache *
pango_win32_font_map_get_font_cache (PangoFontMap *font_map)
{
- g_return_val_if_fail (font_map != NULL, NULL);
+ if (G_UNLIKELY (!font_map))
+ return NULL;
+
g_return_val_if_fail (PANGO_WIN32_IS_FONT_MAP (font_map), NULL);
return PANGO_WIN32_FONT_MAP (font_map)->font_cache;
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index a159426..8678ebb 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -93,6 +93,8 @@ _pango_win32_font_get_hfont (PangoFont *font)
if (!win32font->hfont)
{
cache = pango_win32_font_map_get_font_cache (win32font->fontmap);
+ if (G_UNLIKELY (!cache))
+ return NULL;
win32font->hfont = pango_win32_font_cache_loadw (cache, &win32font->logfontw);
if (!win32font->hfont)
@@ -816,6 +818,8 @@ pango_win32_font_finalize (GObject *object)
{
PangoWin32Font *win32font = (PangoWin32Font *)object;
PangoWin32FontCache *cache = pango_win32_font_map_get_font_cache (win32font->fontmap);
+ if (G_UNLIKELY (!cache))
+ return NULL;
if (win32font->hfont != NULL)
pango_win32_font_cache_unload (cache, win32font->hfont);
@@ -828,9 +832,11 @@ pango_win32_font_finalize (GObject *object)
g_hash_table_destroy (win32font->glyph_info);
- g_assert (win32font->fontmap != NULL);
- g_object_remove_weak_pointer (G_OBJECT (win32font->fontmap), (gpointer *) (gpointer) &win32font->fontmap);
- win32font->fontmap = NULL;
+ if (win32font->fontmap)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (win32font->fontmap), (gpointer *) (gpointer)
&win32font->fontmap);
+ win32font->fontmap = NULL;
+ }
G_OBJECT_CLASS (_pango_win32_font_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]