Re: gdk threads enter/leave not enough?




First, thanks again for your answer!


Tristan Van Berkom <tvb gnome org> wrote:

I never call gtk+ directly but have my own wrappers which take care of
gdk_threads_enter/leave. So I am sure I haven't forgotton it somewhere.

This could be dangerous, you'll deadlock if you call threads_enter from
a signal handler that was launched by a gtk+ widget (because the lock
has to be already aquired for the signal to be dispatched).

Ok, I see, however, in win32 this works. It's strange but true. I
remember, though, that trying my gtk/win32 code on a linux machine did
end up in a deadlock. Thanks again for pointing that out, however, this
is probably not the reason here.

Cool,
     we nailed it then, if your app locks up on a system/installation
that is respecting the gdk_threads_mutex but doesnt on your windows
installation, then calls to gtk/gdk arent waiting for the lock;
landing us in the infamous land of "unpredicted behaviour".

Soooo, the question now is why doesn't the lock work on your system ?
Do other GMutex's work ? or is it just gdk_threads_mutex that doesnt ?


Ok, I sum up my case (and probably file it to bugzilla but I'll wait
for the win32 version of gtk+-2.8 first):

In a win32 environment static user locks ARE respected. However,
gdk_threads_enter/leave behave unexpectly in at least these two cases:

a. You DO can call gdk_threads_enter() inside a button click event's
callback without a deadlock. This should of course not happen. This is
what I tested on a linux environment where the second (explicit) call
to gdk_threads_enter locked up the program infinitely.

b. It is not possible to savely call gtk/gdk functions from different
threads using gdk_threads_enter/leave only (see my original post). In this
case a thread enters gdk_threads_enter() although is shouldn't. My
workaround: Use flags and let gtk functions be called from one thread
only.

All in all it seems that gdk_threads_enter/leave does nothing in my
case ?! Is it possible that I have initiated threads but forgotten
something essential to turn on gdk_threads_enter/leave?

Felix



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