[cairo] Detecting cairo_save/cairo_restore mismatchs

Kalle Vahlman kalle.vahlman at gmail.com
Sat Jul 21 02:32:34 PDT 2007


Hi!

I had a "bang your head against wall for a week and then find a silly
mistake obfuscated by deepish rendering path"-kind of unpleasant
experience with the state saving functions just now, and began to
think that there should be something to check for this.

So, after quick peek&hack at the sources, I made the attached patch to
catch mismatched use of save/restore. The code simply keeps a balance
of the calls and asserts if it's non-zero when the context is
destroyed. This should make debugging such errors easier.

Note, I'm not proposing the patch for inclusion. The docs say that it
is valid to leave the saved status stack unrestored (which is
sensible), the patch does not allow this.

I guess this would be implementable within the cairo trace utility though?

-- 
Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-state-balance-assert.diff
Type: text/x-patch
Size: 1065 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20070721/4a05bc47/attachment.bin 


More information about the cairo mailing list