[cairo-bugs] [Bug 14495] New: 'cairo_restore()' doesn't restore context in error case

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Feb 14 00:30:57 PST 2008


           Summary: 'cairo_restore()' doesn't restore context in error case
           Product: cairo
           Version: 1.5.8
          Platform: x86 (IA32)
        OS/Version: Windows (All)
            Status: NEW
          Severity: enhancement
          Priority: medium
         Component: win32 backend
        AssignedTo: cairo-bugs at cairographics.org
        ReportedBy: iosif.haidu at gmail.com
         QAContact: cairo-bugs at cairographics.org


I would like to proprose to include in the next versions a mechanism that will
allow to specify if 'cairo_restore()' function should restore the previously
saved context even if an error has occured and also clear the error code.

I'm asking that because I have experienced some bad behaviour of windows GDI
API and because of that when I call 'cairo_restore()' the previously saved
context, by 'cairo_save()', is not restored. It would be better if cairo
library will allow developer to choose if it wants to restore or not the old
context in the case of an error.

By 'bad behaviour of windows GDI API' I mean that sometimes some GDI API
returns error when should not (BitBlt(), CreateCompatibleDC() and others). The
error codes are 6 and 8 (extracted with GetLastError()) which coresponds to the
following error messages: "The handle is invalid" and "Not enough storage is
available to process this command". 
I have searched on google about these errors and I discovered that others also
experienced similar situations. Unfortunately I didn't find the real cause and
a fix for this problem.

Anyway, the ideea is that the application I'm working on it is not affected if
these GDI functions doesn't do their job by failuring with the above error
codes, but it is affected by the fact that 'cairo_restore()' doesn't restore
the previously saved context because of these errors. Also it is necessary to
clear the error code inside of 'cairo_restore()' because next time a cairo
function will be called it will exit.

For the application I'm working on it I have done the following modification
for cairo library:
cairo_restore (cairo_t *cr)
// Reset the error code. We want to restore the old context even
//   if an error has occured
if (cr->gstate)
        if (cr->gstate->target)
                cr->gstate->target->status = CAIRO_STATUS_SUCCESS;
//if (cr->status)

This modification suits my application need.

I was thinking maybe you can include such mechanism in the future versions of
cairo library.

Best regards,
Iosif Haidu

Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the cairo-bugs mailing list