Re: Threading Problem



On Tuesday 26 September 2006 23:29, Chris Vine wrote:

>On Saturday 23 September 2006 12:24, Pavel Rojtberg wrote:
>>Since I could not find any gtkmm threading tutorial that covers glib 
>>threads with use of gtkmm, I relied on the pygtk documentation:
http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq20.001.htp

[snip]

> You cannot access GTK+ in more than one thread without using the global GDK
> lock (and you cannot do it all, with or without the GDK lock, under
> windows).
>
> This explains how GTK+ interacts with glib threads:
> http://developer.gnome.org/doc/API/2.0/gdk/gdk-Threads.html
>
> To post events using gtkmm, see Glib::Dispatcher.  You can also use the raw
> C function g_idle_add() if you wish, but this is not wrapped in glibmm
> (presumably because glibmm provides Glib::Dispatcher, which glib does not).
> Either of these will execute the callback in the thread in which the main
> program loop (and by default GTK+) execute, so avoiding the need to use the
> GDK global lock.  If you use g_idle_add(), make sure the handler returns
> FALSE so that it only fires once.

I allowed the fact that you were unable to find any documentation on an 
equivalent to PyGTK's gobject.idle_add() to unduly influence me.  Although I 
never use it in glibmm, it does exist - see 
http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1SignalIdle.html

So you can use either Glib::Dispatcher or Glib::SignalIdle.

Chris




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