[cairo-commit] src/cairo-scaled-font.c

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Mon May 29 15:59:43 PDT 2006


 src/cairo-scaled-font.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

New commits:
diff-tree 0c49666231e42a3f968ad46a0aa58fc7b854b258 (from bafdded8ee43632e5f60307e53f0489be0afc3c4)
Author: Jeff Muizelaar <jeff at freiheit.infidigm.net>
Date:   Sat May 27 02:23:09 2006 -0400

    Only destroy scaled glyphs if they are not in the cache.
    
    Previously, when scaled_glyph_init failed we would destroy the scaled glyph in
    CLEANUP. However, this causes trouble later because there is still a reference
    to the glyph in the cache. This remaining reference causes a number of bad things,
    including a double destruction when the cache is destroyed.

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 8fc3eeb..3ef7804 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -1211,13 +1211,18 @@ _cairo_scaled_glyph_lookup (cairo_scaled
 	/* ask backend to initialize metrics and shape fields */
 	status = (*scaled_font->backend->
 		  scaled_glyph_init) (scaled_font, scaled_glyph, info);
-	if (status)
+	if (status) {
+	    _cairo_scaled_glyph_destroy (scaled_glyph);
 	    goto CLEANUP;
+	}
 
+	/* on success, the cache takes ownership of the scaled_glyph */
 	status = _cairo_cache_insert (scaled_font->glyphs,
 				      &scaled_glyph->cache_entry);
-	if (status)
+	if (status) {
+	    _cairo_scaled_glyph_destroy (scaled_glyph);
 	    goto CLEANUP;
+	}
     }
     /*
      * Check and see if the glyph, as provided,
@@ -1242,8 +1247,6 @@ _cairo_scaled_glyph_lookup (cairo_scaled
   CLEANUP:
     if (status) {
 	_cairo_scaled_font_set_error (scaled_font, status);
-	if (scaled_glyph)
-	    _cairo_scaled_glyph_destroy (scaled_glyph);
 	*scaled_glyph_ret = NULL;
     } else {
 	*scaled_glyph_ret = scaled_glyph;


More information about the cairo-commit mailing list