After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 318851 - g_thread_init should not be called if the glib threads system is already initialized
g_thread_init should not be called if the glib threads system is already init...
Status: VERIFIED FIXED
Product: java-gnome
Classification: Bindings
Component: GTK
Not Applicable
Other All
: Normal enhancement
: ---
Assigned To: Ismael Juma
Ismael Juma
Depends on:
Blocks:
 
 
Reported: 2005-10-14 10:40 UTC by Bodo-Merle Sandor
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
first shot implementation of Gtk.initCheck (3.11 KB, patch)
2005-10-14 15:40 UTC, Bodo-Merle Sandor
none Details | Review

Description Bodo-Merle Sandor 2005-10-14 10:40:50 UTC
Recently i run in a problem, which could be solved with a
Gtk.initCheck functionality in java-gnome. I have a swing program
which uses several threads, and one of the threads fire up a gtk
toplevel window. The problem starts when i use the GNU Classpath to
run my program. As it uses gtk peers, when the java-gnome call its own
Gtk.init method i will get an error message that Gtk is already
initialized and the program quits.
I cant get rid of the Gtk.init from the java-gnome thread because
sometime i use the sun jvm to run the program - which obviously needs
the Gtk.init call. I could check for what kind of jvm i use but that
would be rather ugly.

The actual error message when using jamvm is as follows:

GThread-ERROR **: GThread system may only be initialized once.
aborting...
Comment 1 Bodo-Merle Sandor 2005-10-14 15:40:34 UTC
Created attachment 53471 [details] [review]
first shot implementation of Gtk.initCheck

This is a first quick implementation which just works for me atm. 
This patch doeas not call g_thread_init and does not register gdk_threads_enter
for  atexit.
Comment 2 Bodo-Merle Sandor 2005-10-16 18:55:36 UTC
I realized that the real problem came from g_thread_init being called once from
gnu classpath and once from Gtk.init(). The following patch should fix this issue:

--- src/jni/org_gnu_gtk_Gtk.c   13 Sep 2005 09:06:32 -0000      1.19
+++ src/jni/org_gnu_gtk_Gtk.c   16 Oct 2005 18:36:14 -0000
@@ -48,7 +48,8 @@
      * deadlock behaviour.
      */

-    g_thread_init(NULL);
+    if (!g_thread_supported ())
+       g_thread_init(NULL);
  /* gdk_threads_init(); */

     /*
Comment 3 Ismael Juma 2005-10-16 19:19:53 UTC
Changing Summary to match the actual problem and marking initial patch as obsolete.
Comment 4 Ismael Juma 2005-10-16 19:23:09 UTC
Thanks for the patch. It has been applied to CVS HEAD.