[cairo] [API] cairo_set_error() and friends

Chris Wilson chris at chris-wilson.co.uk
Thu Oct 16 05:46:14 PDT 2008


Often I've need to raise an error on an object in application code. To
date, I've used variations on cairo_path_append(cr, {.status = ERROR})
and then used that context as a source of the desired error object.

I'm currently in the process of running 1.8 through memfault and I'm
trying to find clean ways of propagating the error status. (So that this
time I'll need fewer alterations to the test code and it'll be
acceptable to commit to master.) An example of the problem is
test/clip-nesting.c:

  cr2 = cairo_create (target);
  ... do stuff under a clip...
  cr3 = cairo_create (target);
  ... do stuff under a different clip...
  cairo_destroy (cr3);
  cairo_destroy (cr2);
  ... do stuff to the test context...

Last time, I added a status check and an explicit CAIRO_TEST_NO_MEMORY.
However, this feels like an anathema to the inert error object system.
In the past, we have proposed to infect the target object with the error
from the context. That failed to gain wide acceptance due to the
differing lifetimes of different objects and that the semantics never
quite worked.

So I'm currently considering a simple:
  cairo_set_error (cr, cairo_get_status (cr3));
  cairo_destroy (cr3);
  cairo_set_error (cr, cairo_get_status (cr2));
  cairo_destroy (cr2);

(Wouldn't it be easier if I could just do
  cairo_set_error(cr, cairo_destroy (cr2)?)

Thoughts, suggestions, opinions?
-- 
Chris



More information about the cairo mailing list