changeset 2521:21b17c64df74

6966643: GTK FileDialog hangs when user manually closes it Reviewed-by: art
author dcherepanov
date Tue, 06 Jul 2010 18:23:09 +0400
parents bccf2a4ee318
children 9950dc616615
files src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
diffstat 1 files changed, 25 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Tue Jul 06 17:59:56 2010 +0400
+++ b/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);
 }
 
 /*