[cairo] Error handling patch
cworth at redhat.com
Thu Jul 28 10:06:38 PDT 2005
On Thu, 28 Jul 2005 00:21:03 -0700, Carl Worth wrote:
> Here's a patch to do it. It's rather straightforward I think.
I've just committed this patch as is.
There was one part of it I wanted to fix though:
> @@ -437,8 +437,16 @@ stdio_read_func (png_structp png, png_by
> * given PNG file.
> * Return value: a new #cairo_surface_t initialized with the contents
> - * of the PNG file or %NULL if the file is not a valid PNG file or
> - * memory could not be allocated for the operation.
> + * of the PNG file, or a "nil" surface if any error occurred. A nil
> + * surface can be checked for with cairo_surface_status(surface) which
> + * may return one of the following values:
> + *
> + * CAIRO_STATUS_NO_MEMORY
> + *
> + * XXX: We may want to add a few more error values here, (file not
> + * found? permission denied? file not png?). One way to do this would
> + * be to create several variations on cairo_surface_nil to house the
> + * status values we care about.
Here's a patch that allows cairo_image_surface_create_from_png to
return CAIRO_STATUS_READ_ERROR or a new CAIRO_STATUS_FILE_NOT_FOUND as
appropriate. It uses a not-too-scalable approach of defining two
additional "nil" surface objects. If we end up doing much more of
this, we may want to drop back to create_in_error(), but for now I
think this should work fine.
And, as a bonus, for the first time in this thread, I've actually done
some testing of this code. The create-from-png test now tests that it
can successfully get a FILE_NOT_FOUND error.
If we can get this in right away, I think we're pretty much ready to
push out 0.6.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050728/b53567b4/attachment.pgp
More information about the cairo