[cairo] 1.4.2 release planned for today, 1.4.4 in a few weeks

Chris Wilson chris at chris-wilson.co.uk
Fri Mar 16 13:16:59 PDT 2007


A few more easily caught missing error checks.
--
Chris Wilson.

-------------- next part --------------
>From f4a72a8009737f139b99cdc0fd9aae432ab84639 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri, 16 Mar 2007 18:08:53 +0000
Subject: [PATCH] Check for error status otherwise we may spin for quite some time...

---
 perf/text.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/perf/text.c b/perf/text.c
index de5e0cd..efe7d91 100644
--- a/perf/text.c
+++ b/perf/text.c
@@ -40,14 +40,14 @@ do_text (cairo_t *cr, int width, int height)
 	cairo_move_to (cr, 0, i * 10);
 	cairo_show_text (cr, text + i);
 	cairo_get_current_point (cr, &x, &y);
-	while (x < width) {
+	while (x < width && cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
 	    cairo_show_text (cr, text);
 	    cairo_get_current_point (cr, &x, &y);
 	}
 	i++;
 	if (i >= len)
 	    i = 0;
-    } while (y < height);
+    } while (y < height && cairo_status (cr) == CAIRO_STATUS_SUCCESS);
 
     cairo_perf_timer_stop ();
 
-- 
1.4.4.2

-------------- next part --------------
>From eb2f61a355f626100972d13a690d5cc1d34bb110 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri, 16 Mar 2007 18:40:08 +0000
Subject: [PATCH] Handle malloc failure during scaled_font initialisation.

---
 src/cairo-ft-font.c     |    9 +++++++--
 src/cairo-scaled-font.c |    9 ++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index d2df281..20a2ffb 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -1443,10 +1443,15 @@ _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t	 *unscaled,
     _cairo_font_options_init_copy (&scaled_font->ft_options.base, options);
     _cairo_ft_options_merge (&scaled_font->ft_options, &ft_options);
 
-    _cairo_scaled_font_init (&scaled_font->base,
+    if (_cairo_scaled_font_init (&scaled_font->base,
 			     font_face,
 			     font_matrix, ctm, options,
-			     &cairo_ft_scaled_font_backend);
+			     &cairo_ft_scaled_font_backend)) {
+	_cairo_scaled_font_fini (&scaled_font->base);
+	free (scaled_font);
+	_cairo_ft_unscaled_font_unlock_face (unscaled);
+	return NULL;
+    }
 
     _cairo_ft_unscaled_font_set_scale (unscaled,
 				       &scaled_font->base.scale);
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 0162a0d..1671358 100755
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -366,15 +366,18 @@ _cairo_scaled_font_init (cairo_scaled_font_t               *scaled_font,
 			   &scaled_font->ctm);
 
     CAIRO_MUTEX_INIT (&scaled_font->mutex);
-    scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal,
-					       _cairo_scaled_glyph_destroy,
-					       max_glyphs_cached_per_font);
 
     scaled_font->surface_backend = NULL;
     scaled_font->surface_private = NULL;
 
     scaled_font->backend = backend;
 
+    scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal,
+					       _cairo_scaled_glyph_destroy,
+					       max_glyphs_cached_per_font);
+    if (!scaled_font->glyphs)
+	return CAIRO_STATUS_NO_MEMORY;
+
     return CAIRO_STATUS_SUCCESS;
 }
 
-- 
1.4.4.2

-------------- next part --------------
>From 304e0b7562544b67bfe8a6d1d3651129f71ee971 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri, 16 Mar 2007 18:57:13 +0000
Subject: [PATCH] Handle stroker initialisation failure.

---
 src/cairo-path-stroke.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 09bafbf..ebe7c90 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -67,7 +67,7 @@ typedef struct cairo_stroker {
 } cairo_stroker_t;
 
 /* private functions */
-static void
+static cairo_status_t
 _cairo_stroker_init (cairo_stroker_t		*stroker,
 		     cairo_stroke_style_t	*stroke_style,
 		     cairo_matrix_t		*ctm,
@@ -148,7 +148,7 @@ _cairo_stroker_step_dash (cairo_stroker_t *stroker, double step)
     }
 }
 
-static void
+static cairo_status_t
 _cairo_stroker_init (cairo_stroker_t		*stroker,
 		     cairo_stroke_style_t	*stroke_style,
 		     cairo_matrix_t		*ctm,
@@ -162,10 +162,6 @@ _cairo_stroker_init (cairo_stroker_t		*stroker,
     stroker->tolerance = tolerance;
     stroker->traps = traps;
 
-    _cairo_pen_init (&stroker->pen,
-		     stroke_style->line_width / 2.0,
-		     tolerance, ctm);
-
     stroker->has_current_face = FALSE;
     stroker->has_first_face = FALSE;
     stroker->has_initial_sub_path = FALSE;
@@ -174,6 +170,10 @@ _cairo_stroker_init (cairo_stroker_t		*stroker,
 	_cairo_stroker_start_dash (stroker);
     else
 	stroker->dashed = FALSE;
+
+    return _cairo_pen_init (&stroker->pen,
+		            stroke_style->line_width / 2.0,
+		            tolerance, ctm);
 }
 
 static void
@@ -967,9 +967,11 @@ _cairo_path_fixed_stroke_to_traps (cairo_path_fixed_t	*path,
     if (status != CAIRO_INT_STATUS_UNSUPPORTED)
 	return status;
 
-    _cairo_stroker_init (&stroker, stroke_style,
+    status = _cairo_stroker_init (&stroker, stroke_style,
 			 ctm, ctm_inverse, tolerance,
 			 traps);
+    if (status)
+	goto BAIL;
 
     if (stroker.style->dash)
 	status = _cairo_path_fixed_interpret (path,
-- 
1.4.4.2

-------------- next part --------------
>From 679ba02b7cd1df810cf3542b48cf92530b01adb3 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri, 16 Mar 2007 19:20:10 +0000
Subject: [PATCH] Reset the global cairo_scaled_font_map to NULL after freeing.

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

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 1671358..8fc8d5f 100755
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -213,6 +213,7 @@ _cairo_scaled_font_map_lock (void)
 
  CLEANUP_SCALED_FONT_MAP:
     free (cairo_scaled_font_map);
+    cairo_scaled_font_map = NULL;
  CLEANUP_MUTEX_LOCK:
     CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
     return NULL;
-- 
1.4.4.2

-------------- next part --------------
>From a7e2cee5b29d35291c861e884010e88edd95a8ca Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri, 16 Mar 2007 19:28:25 +0000
Subject: [PATCH] A copy more pattern init failure checks.

---
 src/cairo-gstate.c  |    4 +++-
 src/cairo-pattern.c |    5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index c87eff6..1ed1df9 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -754,7 +754,9 @@ _cairo_gstate_paint (cairo_gstate_t *gstate)
     if (status)
 	return status;
 
-    _cairo_gstate_copy_transformed_source (gstate, &pattern.base);
+    status = _cairo_gstate_copy_transformed_source (gstate, &pattern.base);
+    if (status)
+	return status;
 
     status = _cairo_surface_paint (gstate->target,
 				   gstate->op,
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 697be30..e15e048 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -163,8 +163,11 @@ _cairo_pattern_init_copy (cairo_pattern_t	*pattern,
     } break;
     }
 
+    if (pattern->status)
+	return pattern->status;
+
     pattern->ref_count = 1;
-    return pattern->status;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 void
-- 
1.4.4.2

-------------- next part --------------
>From 2749e50dcebfee5c56ca71f4f0e93ffc764d20ed Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri, 16 Mar 2007 19:35:02 +0000
Subject: [PATCH] Handle failure to allocate a GC.

---
 src/cairo-xlib-surface.c |   51 ++++++++++++++++++++++++++++++---------------
 1 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 6a0d3e4..21fa380 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -51,7 +51,7 @@ typedef int (*cairo_xlib_error_func_t) (Display     *display,
 
 typedef struct _cairo_xlib_surface cairo_xlib_surface_t;
 
-static void
+static cairo_status_t
 _cairo_xlib_surface_ensure_gc (cairo_xlib_surface_t *surface);
 
 static void
@@ -587,22 +587,27 @@ _get_image_surface (cairo_xlib_surface_t    *surface,
 	 * retry, but to keep things simple, we just create a
 	 * temporary pixmap
 	 */
-	Pixmap pixmap = XCreatePixmap (surface->dpy,
+	Pixmap pixmap;
+	cairo_status_t status = _cairo_xlib_surface_ensure_gc (surface);
+	if (status)
+	    return status;
+
+	pixmap = XCreatePixmap (surface->dpy,
 				       surface->drawable,
 				       x2 - x1, y2 - y1,
 				       surface->depth);
-	_cairo_xlib_surface_ensure_gc (surface);
-
-	XCopyArea (surface->dpy, surface->drawable, pixmap, surface->gc,
-		   x1, y1, x2 - x1, y2 - y1, 0, 0);
+	if (pixmap) {
+	    XCopyArea (surface->dpy, surface->drawable, pixmap, surface->gc,
+		       x1, y1, x2 - x1, y2 - y1, 0, 0);
 
-	ximage = XGetImage (surface->dpy,
-			    pixmap,
-			    0, 0,
-			    x2 - x1, y2 - y1,
-			    AllPlanes, ZPixmap);
+	    ximage = XGetImage (surface->dpy,
+				pixmap,
+				0, 0,
+				x2 - x1, y2 - y1,
+				AllPlanes, ZPixmap);
 
-	XFreePixmap (surface->dpy, pixmap);
+	    XFreePixmap (surface->dpy, pixmap);
+	}
     }
     if (!ximage)
 	return CAIRO_STATUS_NO_MEMORY;
@@ -728,18 +733,23 @@ _cairo_xlib_surface_ensure_dst_picture (cairo_xlib_surface_t    *surface)
 
 }
 
-static void
+static cairo_status_t
 _cairo_xlib_surface_ensure_gc (cairo_xlib_surface_t *surface)
 {
     XGCValues gcv;
 
     if (surface->gc)
-	return;
+	return CAIRO_STATUS_SUCCESS;
 
     gcv.graphics_exposures = False;
     surface->gc = XCreateGC (surface->dpy, surface->drawable,
 			     GCGraphicsExposures, &gcv);
+    if (!surface->gc)
+	return CAIRO_STATUS_NO_MEMORY;
+
     _cairo_xlib_surface_set_gc_clip_rects (surface);
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
@@ -755,6 +765,7 @@ _draw_image_surface (cairo_xlib_surface_t   *surface,
     XImage ximage;
     unsigned int bpp, alpha, red, green, blue;
     int native_byte_order = _native_byte_order_lsb () ? LSBFirst : MSBFirst;
+    cairo_status_t status;
 
     pixman_format_get_masks (pixman_image_get_format (image->pixman_image),
 			     &bpp, &alpha, &red, &green, &blue);
@@ -777,7 +788,9 @@ _draw_image_surface (cairo_xlib_surface_t   *surface,
 
     XInitImage (&ximage);
 
-    _cairo_xlib_surface_ensure_gc (surface);
+    status = _cairo_xlib_surface_ensure_gc (surface);
+    if (status)
+	return status;
     XPutImage(surface->dpy, surface->drawable, surface->gc,
 	      &ximage, src_x, src_y, dst_x, dst_y,
 	      width, height);
@@ -1361,7 +1374,9 @@ _cairo_xlib_surface_composite (cairo_operator_t		op,
 	break;
 
     case DO_XCOPYAREA:
-	_cairo_xlib_surface_ensure_gc (dst);
+	status = _cairo_xlib_surface_ensure_gc (dst);
+	if (status)
+	    goto BAIL;
 	XCopyArea (dst->dpy,
 		   src->drawable,
 		   dst->drawable,
@@ -1381,7 +1396,9 @@ _cairo_xlib_surface_composite (cairo_operator_t		op,
 	 * _recategorize_composite_operation.
 	 */
 
-	_cairo_xlib_surface_ensure_gc (dst);
+	status = _cairo_xlib_surface_ensure_gc (dst);
+	if (status)
+	    goto BAIL;
 	_cairo_matrix_is_integer_translation (&src_attr.matrix, &itx, &ity);
 
 	XSetTSOrigin (dst->dpy, dst->gc,
-- 
1.4.4.2

-------------- next part --------------
>From d77a27ca35805b34af25162d533374dcb14c961a Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri, 16 Mar 2007 20:04:26 +0000
Subject: [PATCH] Detect when a substitute image surface is returned for a solid pattern,
and avoid mixed image/xlib composite operations.
---
 src/cairo-xlib-surface.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 21fa380..321857d 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -1214,7 +1214,12 @@ _recategorize_composite_operation (cairo_xlib_surface_t	      *dst,
 {
     cairo_bool_t is_integer_translation =
 	_cairo_matrix_is_integer_translation (&src_attr->matrix, NULL, NULL);
-    cairo_bool_t needs_alpha_composite =
+    cairo_bool_t needs_alpha_composite;
+
+    if (!_cairo_surface_is_xlib (&src->base))
+	return DO_UNSUPPORTED;
+
+    needs_alpha_composite =
 	_operator_needs_alpha_composite (op, _surface_has_alpha (src));
 
     if (!have_mask &&
-- 
1.4.4.2



More information about the cairo mailing list