24 Jan
2014
24 Jan
'14
12:46 a.m.
2014/1/24 mathog <mathog@...1176...>:
In the files in src/display there are many instances of this
Inkscape::DrawingContext::Save save(dc);
First thing, I don't understand the syntax. What does the lower case "save" in that line indicate? The only places "::Save save(" appear in the source code are instances of this line.
This is a RAII idiom object. The constructor calls cairo_save, while its destructor calls cairo_restore. The line essentially means, "call cairo_save now, and call cairo_restore at the end of this scope." https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
If you move this line, some style properties and the drawing transform are not restored to their default after drawing the item, infecting all items which are drawn after it.
Regards, Krzysztof