Re: Gtk2+ and thread safety



Nicholas Allen - Sun Ireland - Software Engineer <nicholas allen ireland sun com> writes:

We are working on a Java peer set for gtk at Sun. We have it pretty
much finished apart from a few bugs which are mostly due to missing
features in Gtk 1.2. It was our original intention to use Gtk+ 1.2 but
we are investigating the possibility of migrating it to 2.0 to fix the
bugs due to missing features in 1.2. I have ported the code to the new
2.0 library but we are now experiencing many thread synchronization
problems. I have read the threading documentation but it does not
appear there is anything extra that we have to do (apart from calling
gdk_threads_init as well as g_threads_init). The code worked fine
under 1.2 but is failing nearly all the time on 2.0.

I think what's probably going on is, from:

 http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html

  GDK is no longer put into threaded mode automatically when
  g_thread_init() has been called. In order to use the global GDK
  thread mutex with gdk_threads_enter() and gdk_threads_leave(), you
  must call gdk_threads_init() explicitly. If you aren't using GDK and
  GTK+ functions from multiple threads, there is no reason to call
  gdk_threads_init().

Regards,
                                        Owen



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