[cairo] Better error return for cairo_pdf_surface_create
Behdad Esfahbod
behdad at behdad.org
Sun Jan 21 04:25:55 PST 2007
On Sat, 2007-01-20 at 15:15 -0500, Nick Wellnhofer wrote:
> Currently, cairo_pdf_surface_create always returns
> CAIRO_STATUS_NO_MEMORY if an error occurs. The attached patch makes it
> possible to distinguish at least between memory and file related errors.
There's also:
https://bugs.freedesktop.org/show_bug.cgi?id=7049
that is about the status returned by stream write function being
ignored. Now fixing that one is harder because you may not get to know
that there is an error condition until the last _destroy() on the
surface. Which leaves the case of changing return type of _destroy()
functions from void to cairo_status_t. Alas, Vlad has another proposal
(hint, hint) to change the return type to int, returning the remaining
ref counts...
behdad
> Nick
>
> plain text document attachment (cairo-pdf-surface-error-return.diff)
> --- mozilla-cvs/gfx/cairo/cairo/src/cairo-pdf-surface.c 2006-12-23 02:15:53.000000000 +0100
> +++ mozilla/gfx/cairo/cairo/src/cairo-pdf-surface.c 2007-01-20 19:28:20.125237000 +0100
> @@ -376,7 +376,15 @@ cairo_pdf_surface_create (const char *f
> status = _cairo_output_stream_get_status (output);
> if (status) {
> _cairo_error (status);
> - return (cairo_surface_t*) &_cairo_surface_nil;
> + switch (status) {
> + case CAIRO_STATUS_READ_ERROR:
> + return (cairo_surface_t*) &_cairo_surface_nil_read_error;
> + case CAIRO_STATUS_WRITE_ERROR:
> + case CAIRO_STATUS_FILE_NOT_FOUND:
> + return (cairo_surface_t*) &_cairo_surface_nil_file_not_found;
> + default:
> + return (cairo_surface_t*) &_cairo_surface_nil;
> + }
> }
>
> return _cairo_pdf_surface_create_for_stream_internal (output,
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
--
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