Re: Problem using Gtk 2.2.1 on WinXP



Daniel K. O. wrote:

Tor Lillqvist wrote:

> Comparing to the sample program at
> http://developer.gnome.org/doc/API/2.0/gdk/gdk-Threads.html , it seems
> that you should surround the call to gtk_main() with
> gdk_threads_enter() and gdk_threads_leave(). Indeed, with this
> addition your test program works.


Thanks. But when I read the docs about gdk_threads_enter/leave funcs I don't remember anything saying that gtk_main() also needs those...

I finaly read the source for that stuff ;-)

in gtk_main(); you have code like this:

gdk_threads_leave();
gtk_main_itteration_do();
gdk_threads_enter();

  (funny how:
       ...
       gdk_threads_enter();
       gtk_main();
       gdk_threads_leave();
       ...
   look like an obvious deadlock without this knowlage)

this way the gdk_threads_mutex is free when callbacks are called and user functions and all
that noize.

you have a few other exeptions such as functions that call XSendEvent and stuff like that; to be wizest on this topic a {grep gdk_threads_ `find gdk_and_gtk_source/ -name "*.[ch]"`} would be in order ;-)

(BTW, gdk_threads_enter() is equivalent to:
if (gdk_threads_mutex) g_mutex_lock(gdk_threads_mutex); and vice versa for gdk_threads_leave() )



> (I don't know why it works as such on Win9x.)

And it worked on my Mandrake 9.1 too.



> *But*, if you are writing a multi-threaded GTK program, please note
> that in general multi-threaded GTK use doesn't work on Windows (yet,
> and don't hold your breath waiting for it to be fixed).

Noooooo! :(
How can I write a GTK+ app for networking? The user clicks on a "Connect" button, and the resolve/connect operation is made in a separated thread. The docs says:

--
"Callbacks require a bit of attention. Callbacks from GTK+ signals are made within the GTK+ lock. However callbacks from GLib (timeouts, IO callbacks, and idle functions) are made outside of the GTK+ lock. So, within a signal handler you do not need to call gdk_threads_enter(), but within the other types of callbacks, you do."
--

So this means that even with a gtk_idle workaround I won't be able to update the GUI?

" multi-threaded GTK use doesn't work on Windows "

is that exactly true ? cant use threads at all ?
no implementation for "g_thread_create()" ?

I have a feeling that this only means that the gdk_threads_enter/leave
implementation is shaky. If that's the case; you can still write a multi-threaded
application with _ONE_THREAD_THAT_UPDATES_THE_GUI_.


Cheers all,
                       -Tristan






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