6966643: GTK FileDialog hangs when user manually closes it
authordcherepanov
Tue, 06 Jul 2010 18:23:09 +0400
changeset 5943 240bcabaca0f
parent 5942 287c421fb9b2
child 5944 1041870341a8
6966643: GTK FileDialog hangs when user manually closes it Reviewed-by: art
jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Tue Jul 06 17:59:56 2010 +0400
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Tue Jul 06 18:23:09 2010 +0400
@@ -42,6 +42,29 @@
             filename);
 }
 
+static void quit(gboolean isSignalHandler)
+{
+    if (dialog != NULL)
+    {
+        // Callbacks from GTK signals are made within the GTK lock
+        // So, within a signal handler there is no need to call
+        // gdk_threads_enter() / fp_gdk_threads_leave()
+        if (!isSignalHandler) {
+            fp_gdk_threads_enter();
+        }
+
+        fp_gtk_widget_hide (dialog);
+        fp_gtk_widget_destroy (dialog);
+
+        fp_gtk_main_quit ();
+        dialog = NULL;
+
+        if (!isSignalHandler) {
+            fp_gdk_threads_leave();
+        }
+    }
+}
+
 /*
  * Class:     sun_awt_X11_GtkFileDialogPeer
  * Method:    quit
@@ -50,18 +73,7 @@
 JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit
 (JNIEnv * env, jobject jpeer)
 {
-    if (dialog != NULL)
-    {
-        fp_gdk_threads_enter();
-
-        fp_gtk_widget_hide (dialog);
-        fp_gtk_widget_destroy (dialog);
-
-        fp_gtk_main_quit ();
-        dialog = NULL;
-
-        fp_gdk_threads_leave();
-    }
+    quit(FALSE);
 }
 
 /**
@@ -147,7 +159,7 @@
             jfilenames);
     fp_g_free(current_folder);
 
-    Java_sun_awt_X11_GtkFileDialogPeer_quit(NULL, NULL);
+    quit(TRUE);
 }
 
 /*