diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-02-02 11:30:35 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-02-02 11:30:35 +0000 |
commit | b56f82723b5a72ca43769526377a90f5916980fc (patch) | |
tree | 98f0cb9e4c3af851517f0091111024f951006e2e /pango/pangoxft-font.c | |
parent | 4380d23fd1695c629b3713e456214de25f187850 (diff) | |
download | pango-b56f82723b5a72ca43769526377a90f5916980fc.tar.gz |
Guard Xft backend agains crashes too.
2006-02-02 Behdad Esfahbod <behdad@gnome.org>
* pango/pangoxft-font.c, pango/pangoxft-render.c: Guard Xft
backend agains crashes too.
Diffstat (limited to 'pango/pangoxft-font.c')
-rw-r--r-- | pango/pangoxft-font.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/pango/pangoxft-font.c b/pango/pangoxft-font.c index c7004c0c..f67d7b5b 100644 --- a/pango/pangoxft-font.c +++ b/pango/pangoxft-font.c @@ -27,6 +27,8 @@ #include "pangoxft-private.h" #include "pangofc-private.h" +PangoXftWarningHistory _pango_xft_warning_history = { FALSE }; + #define PANGO_XFT_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_XFT_FONT, PangoXftFontClass)) #define PANGO_XFT_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_XFT_FONT)) #define PANGO_XFT_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_XFT_FONT, PangoXftFontClass)) @@ -121,7 +123,8 @@ _pango_xft_font_get_mini_font (PangoXftFont *xfont) { PangoFcFont *fcfont = (PangoFcFont *)xfont; - g_assert (fcfont->fontmap); + if (!fcfont || !fcfont->fontmap) + return NULL; if (!xfont->mini_font) { @@ -150,6 +153,8 @@ _pango_xft_font_get_mini_font (PangoXftFont *xfont) pango_font_description_set_size (desc, new_size); xfont->mini_font = pango_font_map_load_font (fcfont->fontmap, context, desc); + if (!xfont->mini_font) + return NULL; pango_font_description_free (desc); g_object_unref (context); @@ -474,7 +479,15 @@ pango_xft_font_real_shutdown (PangoFcFont *fcfont) XftFont * pango_xft_font_get_font (PangoFont *font) { - g_return_val_if_fail (PANGO_XFT_IS_FONT (font), NULL); + if (G_UNLIKELY (!PANGO_XFT_IS_FONT (font))) + { + if (!_pango_xft_warning_history.get_font) + { + _pango_xft_warning_history.get_font = TRUE; + g_critical ("pango_xft_font_get_font called with font == NULL, expect ugly output"); + } + return NULL; + } return xft_font_get_font (font); } |