On Sun, 2007-08-05 at 11:24 +0800, Gregory Hosler wrote: > The main loop is already protected (by threads_enter()/threads_leave() so I > didn't need to add any code at all to the main code (and I don't have any > timeout callbacks either), so the only places I needed to add the > threads_enter/leave was in the threads (2 small ones) themselves.
That's fine, except that you will also need it in any handler called from the glib main loop, such as GIOChannel callbacks, child watch callbacks and any custom GSource objects that you attach to the main loop, where any of these call GDK/GTK+ functions. > having said that... > > > That is why > > using g_idle_add() is often a better approach. > > just looked at the man/devhelp page. Looks interesting. I'm looking for some > code examples. actual working examples would be nice. All you need to do is have an idle handler returning FALSE which calls the GDK/GTK+ functions that you want to have executed from the calling thread. The only other point to remember is that you need to ensure that any data passed by reference via the data argument is still valid when the main loop executes the idle handler, which usually means that you need to allocate it on the heap and free it in the idle handler when you are finished with it. Chris _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list