Re: gdk threads enter/leave not enough?



Fe Kater wrote:
This sounds very strange, are you wrapping all your gtk+ api accessing
code in enter/leave in all threads (including the parent) and only
from event sources (i.e. not in signal handlers that are fired by gtk
widgets) ?


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).

But what do you mean by "including the parent"? Do I have to wrap something
into gdk_threads_enter/leave additionally to the gtk+ calls?

I mean including the the process that called g_thread_create().

Finally, the problems occur especially when the threads are initiated other
than by button press events. (In my case in a listener thread I listen to
digital I/O signals and try to print text output to my own textview logger
widget or even rename labels only.) By the way, I am curious to know if
button press events are automatically locked by gdk_thread_enter().

Yes,
    the core of Gtk+ that listens to events from the X server (or whatever) is
also responsable for aquiring the lock, before letting widgets process events;
gtk+ will release the lock when going to sleep in `poll()' or when dispatching
event sources.

Remember that a "clicked" signal on a GtkButton could have been a result of a real
click, or an application that calls gtk_button_clicked() manualy; so there is no
double standard for the core of Gtk+ and the application code.

Also, incase you didnt pick this up in the tutorial or api docs, you also have to
wrap gtk_main() in an enter/leave pair, this may seem strange but its probably
because you are allowed to nest main-loops (I think gtk_dialog_run does this
for instance).

Cheers,
                            -Tristan



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