Re: Signaling TreeView to update
- From: Joaquim Schmidlap <schmidlap schmidlap org>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: gtkmm-list gnome org
- Subject: Re: Signaling TreeView to update
- Date: Sun, 29 Jul 2007 13:03:27 -0500
On Sun, Jul 29, 2007 at 04:34:05PM +0100, Chris Vine wrote:
> The work-around suggested to you is not safe either if (as it appears)
> you are updating the Gtk::TreeModel from other than the GUI thread -
> that depends on whether doing so invokes any GDK functions in the
> updating thread, but I think it almost certainly does, via the internal
> callbacks of the Gtk:TreeView object. The suggested work-around does
> the software equivalent of waving your mouse over it. The best thing is
> for the thread delivering data to put it onto a thread safe queue and
> then emit from a Glib::Dispatcher object. The callback of the
> Glib::Dispatcher object can then extract from the queue and put the data
> into the Gtk::TreeModel object - Glib::Dispatcher callbacks execute not
> in the signalling thread, but in the thread in which the main program
> loop runs, and is intended for this very purpose. An alternative is to
> go down to the C layer and use g_idle_add() - the glibmm version of this
> is not thread safe for the reasons set out in this thread:
> http://mail.gnome.org/archives/gtkmm-list/2007-January/msg00051.html
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.
I'd be much obliged if someone could point me at some example code...
Thanks to all for the help and contributions.
JS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]