This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui][PATCH] fix GTK FileDialog peer crashes


Hi,

This patch fixes the GTK FileDialog peer crashes.  gnome-vfs's
cancellation code is not thread-safe and we were calling it from
multiple threads.  This caused gnome_vfs_is_primary_thread to fail,
triggering an assertion failure in gnome_vfs_cancellation_cancel.  I've
reported the problem to the gnome-vfs maintainers and they're working on
a solution.  In the mean time, I've fallen back to using GTK's built-in
file chooser backend which is independent from gnome-vfs.  When the
cancellation functions are made thread-safe, we can start using the
gnome-vfs backend again.  The GTK error messages seem to have been
caused by setting the "show_hidden" property -- by default, hidden files
should be hidden in the file selector anyway, so I've removed that line.

Tom

2005-02-10  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c (create):
	Use GTK's built-in file system backend.  Use GTK_RESPONSE_ACCEPT.
	(handle_response): Use GTK_RESPONSE_ACCEPT.

Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c,v
retrieving revision 1.10.4.1
diff -u -r1.10.4.1 gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c	8 Feb 2005 05:22:51 -0000	1.10.4.1
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c	10 Feb 2005 22:48:17 -0000
@@ -61,16 +61,18 @@
   parentp = NSA_GET_PTR(env, parent);
 
   gdk_threads_enter ();
-  
-  widget = gtk_file_chooser_dialog_new("",
-                                       GTK_WINDOW(parentp),
-                                       GTK_FILE_CHOOSER_ACTION_OPEN,
-                                       GTK_STOCK_OK, GTK_RESPONSE_OK,
-                                       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                       NULL);
 
-  /* GtkFileChooser doesn't show hidden files by default. */
-  g_object_set(GTK_FILE_CHOOSER(widget), "show_hidden", TRUE);
+  /* FIXME: we should be using the default gnome-vfs backend but it is
+     not currently thread-safe.  See:
+     http://bugzilla.gnome.org/show_bug.cgi?id=166852 */
+  widget = gtk_file_chooser_dialog_new_with_backend
+    ("Open File",
+     GTK_WINDOW(parentp),
+     GTK_FILE_CHOOSER_ACTION_OPEN,
+     "gtk+",
+     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+     GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+     NULL);
 
   /* GtkFileSelect is not modal by default */
   gtk_window_set_modal (GTK_WINDOW (widget), TRUE);
@@ -221,7 +223,7 @@
   /* We only need this for the case when the user closed the window,
      or clicked ok or cancel. */
   if (responseId != GTK_RESPONSE_DELETE_EVENT
-      && responseId != GTK_RESPONSE_OK
+      && responseId != GTK_RESPONSE_ACCEPT
       && responseId != GTK_RESPONSE_CANCEL)
     return;
 
@@ -245,7 +247,7 @@
     return;
   }
 
-  if (responseId == GTK_RESPONSE_OK) {
+  if (responseId == GTK_RESPONSE_ACCEPT) {
     fileName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (GTK_WIDGET (ptr)));
     str_fileName = (*gdk_env())->NewStringUTF (gdk_env(), fileName);
   }



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]