Re: $drawing_area->queue_draw(); make program crash on some systems



On 4 February 2015 at 12:40, Guillaume van Baalen <postdoc38 yahoo fr> wrote:
I think I found the problem (or at least a workaround).

If the Cairo context $cr in the expose_event sub is a global variable, I get an X error crash. If I set it 
to be local to the sub, as in the code at the end of this message, I don't get an X error anymore, and a 
consistent behaviour across systems.

I can live with that, but am still wondering why I get an error if $cr is global...

Also in case it helps and for future reference, I was able to get some backtrace by breaking on _XError:

AFAIC a cairo context is created for each paint call...
So the CairoContext tends to be unique or each draw cycle.

https://developer.gnome.org/gdk2/stable/gdk2-Cairo-Interaction.html#gdk-cairo-create
"Note that due to double-buffering, Cairo contexts created in a GTK+
expose event handler cannot be cached and reused between different
expose events. "

https://developer.gnome.org/gdk3/stable/gdk3-Cairo-Interaction.html#gdk-cairo-create
"A newly created Cairo context. Free with cairo_destroy() when you are
done drawing."

https://developer.gnome.org/gtk3/stable/chap-drawing-model.html#hierarchical-drawing
"During the Paint phase we will send a single expose event to the
toplevel window. The event handler will create a cairo context for the
window and emit a GtkWidget::draw() signal on it, which will propagate
down the entire widget hierarchy in back-to-front order, using the
clipping and transform of the cairo context. This lets each widget
draw its content at the right place and time, correctly handling
things like partial transparencies and overlapping widgets. "


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]