summaryrefslogtreecommitdiff
path: root/pango/pangocairo-font.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-01-31 00:44:04 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-01-31 00:44:04 +0000
commit4c64086f6cee60fb5275b8fabf2a465212ab8420 (patch)
treed8bcf6e7ba91e91a8c8e7009a828c0c53d91cfc5 /pango/pangocairo-font.c
parent71f0113fe55447c026fb00115c552a8762bf9e91 (diff)
downloadpango-4c64086f6cee60fb5275b8fabf2a465212ab8420.tar.gz
Improve error handling in high-frequency functions: Only warn once.
2006-01-30 Behdad Esfahbod <behdad@gnome.org> * pango/shape.c (pango_shape): * pango/fonts.c (pango_font_get_glyph_extents): * pango/pangocairo-font.c (_pango_cairo_font_install): Improve error handling in high-frequency functions: Only warn once. * pango-impl-utils.h, pangoutils.h: * pangocairo-private.h, pangocairo-font.c: Add machinery for above: _pango_warning_history and _pango_cairo_warning_history.
Diffstat (limited to 'pango/pangocairo-font.c')
-rw-r--r--pango/pangocairo-font.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index a727e053..ee98020f 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -21,10 +21,13 @@
#include <config.h>
+#include "pango-impl-utils.h"
#include "pangocairo.h"
#include "pangocairo-private.h"
#include "pango-utils.h"
+PangoCairoWarningHistory _pango_cairo_warning_history = {};
+
GType
pango_cairo_font_get_type (void)
{
@@ -68,7 +71,15 @@ void
_pango_cairo_font_install (PangoCairoFont *font,
cairo_t *cr)
{
- g_return_if_fail (PANGO_IS_CAIRO_FONT (font));
+ if (G_UNLIKELY (!PANGO_IS_CAIRO_FONT (font)))
+ {
+ if (!_pango_cairo_warning_history.font_install)
+ {
+ _pango_cairo_warning_history.font_install = TRUE;
+ g_critical ("_pango_cairo_font_install called with font == NULL, expect ugly output");
+ }
+ return;
+ }
(* PANGO_CAIRO_FONT_GET_IFACE (font)->install) (font, cr);
}