[cairo] [cairo-commit] test/surface-source.c

Carl Worth cworth at cworth.org
Mon Sep 29 14:11:12 PDT 2008


On Mon, 2008-09-29 at 07:33 -0700, Chris Wilson wrote:
>     [test/xlib-surface-source] Fix ill-timed XCloseDisplay
>     
>     Sigh - finding a crasher in xlib seemed too good to be true. And it was.
>     The bug is due to the coupling of the XCloseDisplay with the user_data on
>     the source surface.
>     
>     This was an externally trigger XCloseDisplay whilst the user had live
>     surfaces, so I consider this a gross application bug and therefore does
>     not require graceful handling within cairo-xlib. However, I'm willing to
>     listen to reason...
...
> @@ -101,7 +101,6 @@ draw (cairo_t *cr, int width, int height)
>      cairo_set_source_surface (cr2, surface,
>  			      (INTER_SIZE - SOURCE_SIZE)/2,
>  			      (INTER_SIZE - SOURCE_SIZE)/2);
> -    cairo_surface_destroy (surface);
>      cairo_paint (cr2);
>  
>      /* and then paint onto a small surface for checking */
> @@ -112,6 +111,9 @@ draw (cairo_t *cr, int width, int height)
>      cairo_rectangle (cr, 15, 15, 60, 60);
>      cairo_fill (cr);
>  
> +    /* destroy the surface last, as this triggers XCloseDisplay */
> +    cairo_surface_destroy (surface);
> +
>      return CAIRO_TEST_SUCCESS;

Can I try to be the voice of reason here?

And idiom like:

	cairo_set_source_surface (cr, surface);
	cairo_surface_destroy (surface);

is fairly common in our documentation, (handing an object to cairo for
it to reference, and dropping the application's reference). Why should
that be illegal here?

-Carl




More information about the cairo mailing list