В Чтв, 05/07/2007 в 10:38 +0200, Sebastian Pölsterl пишет: > Nickolay V. Shmyrev schrieb: > > В Пнд, 02/07/2007 в 22:01 +0200, Sebastian Pölsterl пишет: > >> -----BEGIN PGP SIGNED MESSAGE----- > >> Hash: SHA1 > >> > >> blog entry at http://www.k-d-w.org/news/17/15.html > >> > >> Hi! > >> > >> Unfortunatly, I made even less changes to Deskbar-Applet than last week. > >> I did some minor changes and > >> started on integrating new-stuff-manager[1] support for Deskbar. > >> > >> I ran into a very annoying problem with threads in GTK+. I know that > >> GTK+ is only thread-aware and you > >> have to surround the critical parts with gtk.gdk.threads_enter() and > >> gtk.gdk.threads_leave(). I already did > >> this where the results are added to the ListStore/TreeView storing the > >> matches. However, now and then I get > >> a Xlib asynchronous error. I couldn't find a situation where I can > >> reproduce this error reliably. I would be > >> glad if anybody could give some tips on working with threads and GTK+. > > > > Looking at your main file: > > > > http://svn.gnome.org/viewcvs/deskbar-applet/branches/GSOC_2007/deskbar/gsoc_deskbar.py?revision=1328&view=markup > > > > I see gtk.main() isn't surrounded by gdk.threads_enter/leave(). It's > > probably not the case in python but in C you have to surround mainloop > > by locks: > > > > http://developer.gnome.org/doc/API/2.0/gdk/gdk-Threads.html > > > > I may be wrong though > The problem is that I only call gtk.main() if the applet has been > started in debug mode (i.e. in a separate window). If the Deskbar runs > as applet there's no gtk.main call. No matter, mainloop is started in gnomeapplet.bonobo_factory then. But it should be protected in any case. But since it's all too complicated and multithreaded gui isn't that good there is probably sense to access gtk only from a main thread and schedule all actions from different threads on idle. This way work will be much more stable.
Attachment:
signature.asc
Description: =?koi8-r?Q?=FC=D4=C1?= =?koi8-r?Q?_=DE=C1=D3=D4=D8?= =?koi8-r?Q?_=D3=CF=CF=C2=DD=C5=CE=C9=D1?= =?koi8-r?Q?_=D0=CF=C4=D0=C9=D3=C1=CE=C1?= =?koi8-r?Q?_=C3=C9=C6=D2=CF=D7=CF=CA?= =?koi8-r?Q?_=D0=CF=C4=D0=C9=D3=D8=C0?=