[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: gtk initialization cleanups
From: |
Mark Wielaard |
Subject: |
FYI: gtk initialization cleanups |
Date: |
Fri, 09 Jul 2004 13:06:40 +0200 |
Hi,
Found some issues where the gdk_env wasn't setup correctly when a
callback was called. The following patch tries to make sure it has been
setup correctly before any gdk/gtk functions are ever called.
2004-08-08 Mark Wielaard <address@hidden>
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
(Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): Initialize
gdk_env before calling any gdk or gtk function.
* gnu/java/awt/peer/gtk/GtkMainThread.java (gtkInitCalled): New field.
(GtkMainThread): Call wait() in while loop waiting for gtkInitCalled.
(run): Set gtkInitCalled.
With this under kissme I cannot trigger any AWT/Gtk+ related crashes
anymore (with simple widgets, but see bug #9484 for issues with image
loading - without showing any gtk widgets). Under jamvm I do still
occasionally trigger the bug, but much less frequently than before.
All this might be related to the problems we were seeing with
portable-native-sync code and rvm. But sadly I didn't get AWT working
with rvm yet.
Cheers,
Mark
Index: gnu/java/awt/peer/gtk/GtkMainThread.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkMainThread.java,v
retrieving revision 1.12
diff -u -r1.12 GtkMainThread.java
--- gnu/java/awt/peer/gtk/GtkMainThread.java 7 Jul 2004 04:26:40 -0000
1.12
+++ gnu/java/awt/peer/gtk/GtkMainThread.java 9 Jul 2004 10:57:39 -0000
@@ -43,6 +43,9 @@
private static Thread mainThread = null;
private static Object mainThreadLock = new Object();
+ // Whether the gtk+ subsystem has been initialized.
+ private boolean gtkInitCalled = false;
+
/**
* Call gtk_init. It is very important that this happen before any other
* gtk calls.
@@ -67,9 +70,15 @@
synchronized (this)
{
mainThread.start();
- try {
- wait();
- } catch (InterruptedException e) { }
+
+ while (!gtkInitCalled)
+ {
+ try
+ {
+ wait();
+ }
+ catch (InterruptedException e) { }
+ }
}
}
@@ -91,7 +100,8 @@
synchronized (this)
{
gtkInit(portableNativeSync);
- notify();
+ gtkInitCalled = true;
+ notifyAll();
}
gtkMain();
}
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
===================================================================
RCS file:
/cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c,v
retrieving revision 1.21
diff -u -r1.21 gnu_java_awt_peer_gtk_GtkMainThread.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c 7 Jul 2004
04:26:40 -0000 1.21
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c 9 Jul 2004
10:57:39 -0000
@@ -96,6 +96,7 @@
gtkmenuitempeer, gtktextcomponentpeer, window;
NSA_INIT (env, clazz);
+ gdk_env = env;
/* GTK requires a program's argc and argv variables, and requires that they
be valid. Set it up. */
@@ -125,7 +126,6 @@
we're shutting down. */
atexit (gdk_threads_enter);
- gdk_env = env;
gdk_event_handler_set ((GdkEventFunc)awt_event_handler, NULL, NULL);
if ((homedir = getenv ("HOME")))
signature.asc
Description: This is a digitally signed message part
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: gtk initialization cleanups,
Mark Wielaard <=