Re: [gtk-list] Re: gdk_thread_leave() in call back func, otherwise dead lock.




Sebastian Wilhelmi <wilhelmi@ira.uka.de> writes:

> Hi Yasushi,

> > My question is:
> > 
> > - Is it ok to call gdk_thread_leave() in call-back function, if the
> >   function does not call any gtk functions?
> 
> Yes, thats perfectly fine, but as long as you're blocking inside a callback
> (and that is what is happening here), you have an unresponding interface. It
> might be better to just set loop_going to 0 and let loop_thread() notify the
> main thread via a gtk signal as the last command it executes before it closes
> down, If of course loop_thread() has a very low latency like in this example,
> this might be overkill. Remember however to relock the gdk-mutex before
> leaving the signal handler!

Just to clarify - signals are always executed in the current thread.
To notify the main thread, you'd have to use a different mechanism.
The most convenient one is probably g_idle_add() - the idle you
add will get executed in the main thread.

(You can use g_idle_add_full() to set a higher priority for the
idle function if you don't want to wait for the main thread to go
idle.)

Regards,
                                             Owen



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