[cairo] Idle thoughts on error propagation

Behdad Esfahbod behdad at behdad.org
Thu May 1 14:52:07 PDT 2008


On Thu, 2008-05-01 at 22:46 +0100, Chris Wilson wrote:
> Ideally (like firefox)
> we'd like to write:
>    surface = cairo_surface_create ();
>    cr = cairo_create (surface);
>    /* do stuff */
>    cairo_destroy (cr);
>    status = cairo_surface_destroy (surface);
>    if (status)
>        return ERROR;
> 
> As this also correctly propagates the drawing error into any patterns
> derived from the surface.
> 
> Basically, I'm thinking along the lines of:
> diff --git a/src/cairo.c b/src/cairo.c
> index e44fbef..8a60b5b 100644
> --- a/src/cairo.c
> +++ b/src/cairo.c
> @@ -116,6 +116,9 @@ _cairo_set_error (cairo_t *cr, cairo_status_t
> status)
>       * error, which is the most significant. */
>      _cairo_status_set_error (&cr->status, status);
>  
> +    if (cr->gstate != NULL && cr->gstate->original_target != NULL)
> +       status = _cairo_surface_set_error
> (cr->gstate->original_target, status);
> +
>      status = _cairo_error (status);
>  }
> 
> Just an idle thought. :-)

Sounds like the right thing to do.

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list