[cairo] reference counting vs garbage collection

Keith Packard keithp at keithp.com
Mon Jan 3 12:16:29 PST 2005


Around 13 o'clock on Jan 3, Owen Taylor wrote:

> Maybe the interface to these functions is just wrong? Why don't we
> just have:
> 
>  cairo_image_surface_create()
>  [...]
>  cairo_image_surface_save_png()

cairo provides 'cairo_show_page' and 'cairo_copy_page' entry points which
perform this task for png files.  The problem here is that when a png file
is closed without the application having first called copy_page or
show_page, cairo automatically calls copy_page to dump the image to the
file.  

That this magic (but helpful) file writing occurs in the library at an
ill-specified time (the last call to cairo_surface_destroy, which may well
be a side-effect of some other cairo call) means that the application
doesn't really know what cairo will do at any particular call.

I'm currently kludging around this by tracking calls to copy_page/
show_page myself, and forcing a call to copy_page in the Surface::destroy 
function, "knowing" that cairo won't touch the file after this point from
cairo_surface_destroy.  An interface which didn't force me to assume a 
particular behaviour from the library seems prudent.

-keith


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050103/19836769/attachment.pgp


More information about the cairo mailing list