[pygtk] Refreshing a Tree Store/Tree View within a thread crashes randomly

Lionel Dricot zeploum at gmail.com
Sun Jan 25 10:57:13 WST 2009


Hello,

I'm displaying a TreeStore in a TreeView and I want to refresh them when I
receive the gobject signal "refresh".

Because my refresh can be heavy and I don't want to refresh 10 times when
not needed, the refresh is handled in a thread. The principle is the
following :

SignalEmitter.connect("refresh",self.do_refresh)

do_refresh()
    thread(self.general_refresh)

general_refresh()
    if self.lock.acquire(False) :
        refresh_treestore()
        self.lock.release()

refresh_treestore() :
At first, I was emptying the TreeStore then added the elements but I've seen
somewhere on the web that it might be better to create a new TreeStore then
to set_model on the TreeView


Unfortunatly, it crashes randomly with the error :

/home/ploum/code/gtg/taskbrowser/browser.py:180: GtkWarning:
gtk_tree_store_get_value: assertion `VALID_ITER (iter, tree_store)' failed
  gtk.main()
/home/ploum/code/gtg/taskbrowser/browser.py:180: Warning:
g_object_set_property: assertion `G_IS_VALUE (value)' failed
  gtk.main()
/home/ploum/code/gtg/taskbrowser/browser.py:180: Warning: g_value_unset:
assertion `G_IS_VALUE (value)' failed
  gtk.main()

The crash can happen at start, it can happen after 10 minutes, it's
completely random. Also, the crash always happens after the lock is
released.

I've no idea why it crashes like this and any help would be greatly
appreciated !


If you are motivated enough to try the real code, I've put a bzr branch on
https://code.edge.launchpad.net/~gtg/gtg/threaded. simply do :

bzr branch lp:~gtg/gtg/threaded

The code is in taskbrowser/browser.py  (refresh_treestore is called
refresh_ts).

(and if you want to see the application in its normal shape, just do bzr
branch lp:gtg )

Thanks a lot for your (future) help,

Lionel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20090125/73c23103/attachment.htm 


More information about the pygtk mailing list