Re: Signaling TreeView to update



On Sun, 2007-07-29 at 13:03 -0500, Joaquim Schmidlap wrote:
> I did indeed have to wrap my writes to the Gtk::TreeModel with
> gdk_threads_enter and _leave. Once I did so, the app performs stably, no
> core dumps, etc.
> 
> I'd be happy to post the data back to the main thread via a Dispatcher, and
> it would indeed result in cleaner code (and possibly improve performance by
> eliminating the global lock). But I can't find a decent example of how to
> get arbitrary data from point A to point B. The documenation for
> Glib::Dispatcher that I've seen is quite thin, and I can't see anyway to
> communicate any data back to the receiving thread. Perhaps I haven't found
> the right doc, or perhaps all it does is "void" signaling and I am on my own
> for implementing a queue.

Yes you are on your own for implementing a queue.  You can use a
GAsyncQueue (not wrapped for glibmm) at:
http://developer.gnome.org/doc/API/2.0/glib/glib-Asynchronous-Queues.html

or for something more C++-like, something like this:
http://efax-gtk.cvs.sourceforge.net/*checkout*/efax-gtk/efax-gtk/src/utils/async_queue.h

However, for your kind of usage I would use g_idle_add().  Make sure
that the callback returns false so that it only fires once.  Pass the
data on freestore and free it in the callback when you have finished
with it.  Strictly speaking the callback you pass to g_idle_add() should
have C linkage (ie be declared extern "C" and if necessary made a friend
of any associated class, which you can pass as the data argument), but
you can usually get away with a static member function - g++ allows
this.

Chris




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