Bug 7049 - cairo_*_destroy() lack status return
Summary: cairo_*_destroy() lack status return
Status: RESOLVED MOVED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.1.7
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-27 15:28 UTC by Steve Chaplin
Modified: 2018-08-25 13:57 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
demonstrate that error status is not reported (1.94 KB, text/plain)
2006-05-27 15:31 UTC, Steve Chaplin
Details
Updated test case with explicit cairo_surface_finish() (2.33 KB, text/x-csrc)
2007-09-25 16:55 UTC, Chris Wilson
Details

Description Steve Chaplin 2006-05-27 15:28:50 UTC
I'm trying to add PS/PDF/SVG stream support to pycairo and want to make sure
that exceptions are raised when a stream write error occurs. The stream write
function returns CAIRO_STATUS_WRITE_ERROR on a write error but the surface and
cairo context ignore this and are not given an error status. So what is the
purpose of returning CAIRO_STATUS_WRITE_ERROR?

The attached program demonstrates stream errors, for me it outputs:
status (CAIRO_STATUS_SUCCESS is 0)
libpng error: Write Error
PNG 1
PS  0, 0
PS  0, 0
PS  0, 0
I/O error : flush error

I would expect all the status numbers to be non-zero (like PNG).
Comment 1 Steve Chaplin 2006-05-27 15:31:18 UTC
Created attachment 5747 [details]
demonstrate that error status is not reported
Comment 2 Chris Wilson 2007-09-25 16:54:51 UTC
The problem with the test case is that the surfaces do not attempt to write to the stream until cairo_surface_finish() (in this case called implicitly from cairo_surface_destroy) at which point the error status has been silently lost.

After adding cairo_surface_finish() before the cairo_surface_status(), the test output becomes:
status (CAIRO_STATUS_SUCCESS is 0)
PNG 11 (error while writing to output stream)
PS   0 (success), 11 (error while writing to output stream)
PDF  0 (success), 11 (error while writing to output stream)
SVG  0 (success), 11 (error while writing to output stream)
Comment 3 Chris Wilson 2007-09-25 16:55:33 UTC
Created attachment 11755 [details]
Updated test case with explicit cairo_surface_finish()
Comment 4 Chris Wilson 2008-09-29 03:36:45 UTC
Stephen, I've added test cases to ensure that a write error is propagated back to the application - but given the API constraints the application must call cairo_surface_finish() explicitly to ensure that the surface is written out (which requires fiddling with cairo_surface_get_refererence_count() in its surface_destroy function for PyCairo to support throwing exceptions from write-out). Retitling to reflect issue with current cairo_*_destroy() API.
Comment 5 Behdad Esfahbod 2008-09-29 04:58:17 UTC
We've discussed changing _destroy() functions to return cairo_status before.  Not sure how nicely that maps to language bindings though.
Comment 6 GitLab Migration User 2018-08-25 13:57:13 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/285.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.