[PATCH] [scaled-font] Differentiate fatal error when creating fonts

Chris Wilson chris at chris-wilson.co.uk
Mon Jan 26 13:11:41 PST 2009


We only want to set the error state on the backend when it implies that
the font-face is in an inconsistent state. For example, this may be due to
a locking error in the backend or that we have detected a corrupt font.

In contrast, if we merely fail to allocated the scaled font then we just
wish to return that error to the user, without making the font-face itself
inert.
---
 src/cairo-scaled-font.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 912dac5..7d60e5f 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -1039,15 +1039,21 @@ cairo_scaled_font_create (cairo_font_face_t          *font_face,
     /* Otherwise create it and insert it into the hash table. */
     status = font_face->backend->scaled_font_create (font_face, font_matrix,
 						     ctm, options, &scaled_font);
+    /* Did we leave the backend in an error state? */
     if (unlikely (status)) {
 	_cairo_scaled_font_map_unlock ();
 	status = _cairo_font_face_set_error (font_face, status);
 	return _cairo_scaled_font_create_in_error (status);
     }
+    /* Or did we encounter an error whilst constructing the scaled font? */
+    if (unlikely (scaled_font->status)) {
+	_cairo_scaled_font_map_unlock ();
+	return scaled_font;
+    }
 
     status = _cairo_hash_table_insert (font_map->hash_table,
 				       &scaled_font->hash_entry);
-    if (status == CAIRO_STATUS_SUCCESS) {
+    if (likely (status == CAIRO_STATUS_SUCCESS)) {
 	old = font_map->mru_scaled_font;
 	font_map->mru_scaled_font = scaled_font;
 	_cairo_reference_count_inc (&scaled_font->ref_count);
-- 
1.6.0.4


--=-eOh/xoSIvGBTom+9YKG9
Content-Disposition: attachment; filename*0=0026--ft-font-Distinguish-fatal-backend-errors-whilst-co.patc; filename*1=h
Content-Type: text/x-patch; name="0026--ft-font-Distinguish-fatal-backend-errors-whilst-co.patch"; charset="UTF-8"
Content-Transfer-Encoding: 7bit



More information about the cairo mailing list