[cairo] 'cairo_restore()' doesn't restore context in error case

Carl Worth cworth at cworth.org
Tue Feb 19 14:02:11 PST 2008


On Tue, 19 Feb 2008 23:00:15 +0200, "Iosif Haidu" wrote:
> On Tue, Feb 19, 2008 at 3:32 AM, Behdad Esfahbod <behdad at behdad.org> wrote:
> > On Sat, 2008-02-16 at 00:50 +0200, Iosif Haidu wrote:
> > >> it. For an unknown reason sometime some windows gdi functions
> > >> (CreateCompatibleDC(), BitBlt() and other) fail to execute with error
> > >> code 6 and 8. In this situation the cairo function responsible with
> > >> that windows gdi function call will set the error status to
> > >> CAIRO_STATUS_NO_MEMORY and the 'cairo_restore()' will not restore the
> > >> cairo context. I have noticed that cairo context actually has not been
> > >> damaged by the failure of the windows gdi function, yet the context is
> > >> not restored.
>
> > > As I said on the bug, the this is a bug that should be fixed.  If the
> > > failing gdi functions are not fatal, this should be handled in
> > > cairo.

Definitely. If there are non-fatal things happening in the underlying
system, then cairo is broken by considering it an error. Even if the
errors are fatal, cairo is broken by calling them NO_MEMORY if that's
not the case, (maybe we need CAIRO_STATUS_GDI_MYSTIC_PROBLEM or
something?).

> Actually, yes. Resetting their status to SUCCESS will magically make them
> continue working, because nothing is damaged in the cairo context structure
> if a windows gdi function fails.

Please read again what I quoted above. If you're talking about
non-fatal "errors" from GDI, then the fix is to make cairo not treat
those as an error.

Meanwhile, your proposal to make cairo_restore() clear all errors
*would* require auditing/fixing all of the cairo implementation for
errors other than GDI errors. Are you certain that none of them leave
any damage around?

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080219/8dcc09bb/attachment.pgp 


More information about the cairo mailing list