[cairo] reference counting vs garbage collection
Owen Taylor
otaylor at redhat.com
Mon Jan 3 12:48:09 PST 2005
On Mon, 2005-01-03 at 12:16 -0800, Keith Packard wrote:
> 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.
What I'm saying is that the whole fact of having a "PNG surface" with
a persistant FILE * is an artifact of doing the API in a weird way
and that if we simply take advantage of being pre-1.0 and rework the
API
to avoid that then we avoid the problem.
Regards,
Owen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050103/9c4a27ae/attachment.pgp
More information about the cairo
mailing list