Nikolaj KiƦr Thygesen wrote:
> Hey list,
> 
> I'm currently writing a multi threaded gtk-app, and knowing that
> calling gtk_main() simultaneously from different threads is a no-go,

it's more subtle: calling gtk functions simultaneous from different
threads is a no-go. gtk (and X) is not thread-safe. So as long as your
app does not call multiple gtk functions simultaneously it will work.

> I was quite surprised to find that the following fragment seemed to
> work when being accidentally called from a thread different from the
> one which originally called gtk_main()!! I have initialized the
> threading support properly before the initial call to gtk_main() in
> the main thread, so I guess gdk_threads_enter() momentarily exits the
> original gtk_main() - yes??? Is this really supposed to work, or did
> I just get lucky???
> 
> gdk_threads_enter();
> ...
> gtk_main();
> gdk_threads_leave();

if I understand things correctly, gdk_threads_enter(); just makes sure
there is no other thread at that moment doing something inside a
not-thread-safe-function, and executes your block if that condition is
OK. So you can do anything inside the
gdk_threads_enter();/gdk_threads_leave(); block, except another call to
gdk_threads_enter();

regards,
        Olivier
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to