[cairo] misc. cairo_t questions

Andrea Canciani ranma42 at gmail.com
Thu Apr 12 13:02:43 PDT 2012

On Thu, Apr 12, 2012 at 10:00 PM, Roger Davis <rbd at soest.hawaii.edu> wrote:
> Hi Uri,
> Thanks for your help! One followup question:
>>> (3) It seems like almost all of the cairo_set...(), etc., functions
>>> return void. Is there a standard behavior in place to handle bad arguments
>>> to these calls, or other error conditions?
>> Yes. If some object gets in an error condition, this error condition is
>> sticky. You can not un-error something afterwards. To get this error flag,
>> there are cairo_status(), cairo_surface_status(), cairo_pattern_status(),
>> ....
> I like to be reasonably rigorous in error checking (and am extremely averse
> to allowing situations that could result in a core dump), but it does seem
> like overkill to do a cairo_status() after every single change to a context
> or after every drawing operation. Are there certain operations to contexts
> or surfaces in particular which are unusually prone to error generation,
> especially errors which might ultimately lead to a core dump, which it would
> be useful to check via cairo_???_status()? By the way, checking status after
> cairo_select_font_face(cr, "NonexistentFont" ...) doesn't yield any abnormal
> error code, so I'm wondering when these functions might actually return
> useful information. Perhaps this particular case is non-representative since
> it is, as you say, from the toy API.

The API is designed so that as soon as an object gets into an error
status, it will never change anymore.
It will just ignore any operation, so operations on an error object
should never cause core dumps or misbehaviors.

More information about the cairo mailing list