Re: Status report 'Refactoring Deskbar-Applet' 02.07.2007



Nickolay V. Shmyrev schrieb:
> В Чтв, 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.
Because everybody gives me the advice to use idle_add instead, I gave it
a try. The method that appends the results to the TreeView/TreeStore is
now called with idle_add. It works well only in some cases. I don't get
an error or crash now, instead no results are shown.

Now I don't know where to search for the cause of this problem :( Please
help me !!!

Some more details on how it should work:
If the user types in something and the text didn't change for 250 ms
each module is queried. Querying the modules works asynchronously (for
each module the query method is called in a thread) and each module
emits a signal if it collected the results. A callback function connects
to those signals and adds the results to the TreeView/TreeStore. If the
entry changed, the TreeView/TreeStore is cleared.

-- 
Greetings,
Sebastian Pölsterl



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