[cairo] Better error return for cairo_pdf_surface_create

Nick Wellnhofer wellnhofer at aevum.de
Sat Jan 20 12:15:36 PST 2007


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.

Nick

-------------- next part --------------
--- 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,


More information about the cairo mailing list