Re: Drawing from thread



On Fri, May 8, 2009 at 12:35 PM, Mohith Manoj <mohithmanoj gmail com> wrote:
> I have a gtkmm application in which there is a running waveform widget
> (custom of course) which draws a waveform from left to right and in
> real-time. I feed data to the widget from a timer, which is then stored
> inside the widget until it is drawn. The drawing operation is triggered from
> another process (a thread).
>
> When I test the setup in my target (a DirectFB based system), it all goes
> well. But in my machine (X11) it crashes with the following backtrace
> <My_App_Name>: xcb_lock.c:33: _XCBUnlockDisplay: Assertion
> `xcb_get_request_sent(dpy->xcb->connection) == dpy->request' failed.
> Locking assertion failure.  Backtrace:
> #0 /usr/lib/libxcb-xlib.so.0 [0x11e767]
> #1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_lock+0x2e) [0x11e90e]
> #2 /usr/lib/libX11.so.6 [0x496159]
> #3 /usr/lib/libX11.so.6(XUngrabPointer+0x25) [0x48bda5]
> #4 /usr/lib/libgdk-x11-2.0.so.0(gdk_display_pointer_ungrab+0x99) [0x7d24d09]
> #5 /usr/lib/libgdk-x11-2.0.so.0(gdk_pointer_ungrab+0x1a) [0x7cffbca]
> #6 /usr/lib/gtk-2.0/modules/libgnomebreakpad.so [0x84319e]
> #7 /usr/lib/gtk-2.0/modules/libgnomebreakpad.so [0x8436e5]
> #8 [0x9c9400]
> #9 [0x9c9416]
> #10 /lib/libc.so.6(gsignal+0x50) [0xdd0450]
> #11 /lib/libc.so.6(abort+0x188) [0xdd1e18]
> #12 /lib/libc.so.6(__assert_fail+0xee) [0xdc93fe]
> #13 /usr/lib/libX11.so.6 [0x4960ee]
> #14 /usr/lib/libXrender.so.1(XRenderCompositeTrapezoids+0x1fc) [0x6bd3bc]
> #15 /usr/lib/libcairo.so.2 [0x7cb6d87]
> #16 /usr/lib/libcairo.so.2 [0x7c9b921]
> #17 /usr/lib/libcairo.so.2 [0x7c9f474]
> #18 /usr/lib/libcairo.so.2 [0x7c9e547]
> #19 /usr/lib/libcairo.so.2 [0x7c9ef65]
> RedWheel: xcb_lock.c:77: _XGetXCBBuffer: Assertion `((int) ((xcb_req) -
> (dpy->request)) >= 0)' failed.
> Multiple segmentation faults occurred; can't display error dialog
>
> Any idea what going on?
>
> Also when I draw to a surface from another process (which did not create the
> surface), is there anything else I should be doing. I am using cairo for all
> my drawing needs.
>

Hello!

GUI operations should always be performed on the GUI thread, because
GUI items are not thread safe. If I understood well, you are issuing
drawing operations directly from other threads (if this is what
"triggered" means). Instead of this, you should create a
Glib::Dispatcher on the GUI thread, connect a separate drawing method
to the dispatcher, and then use the dispatcher from other threads to
notify the GUI thread that it should perform some drawing.
See here: http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1Dispatcher.html
for details.

HTH

Andras


> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
>


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