summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2015-02-02 17:55:22 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2015-02-02 17:55:22 +0000
commiteebda637fae8559d69d1d80818288abf407c7dc9 (patch)
tree2df6103901e0bfb7b5b4eadd5e3f8217d2091cbb /src
parent62ed929ea533619df99debde5797b37dda3eae06 (diff)
Fix Linux/Unix potential program hang when dialog pops up while a menu is open (STR #3179).
This patch does not fix all issues though. The hang does not happen anymore, but with some WM's the dialog can show up underneath the menu. This needs more investigation, but this fixes the more important issue. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10550 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/fl_file_dir.cxx29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/fl_file_dir.cxx b/src/fl_file_dir.cxx
index 6ee7bf3c0..e9ad97529 100644
--- a/src/fl_file_dir.cxx
+++ b/src/fl_file_dir.cxx
@@ -3,7 +3,7 @@
//
// File chooser widget for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2015 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -33,6 +33,22 @@ static void callback(Fl_File_Chooser *, void*) {
(*current_callback)(fc->value());
}
+// Pop up a file chooser dialog window and wait until it is closed...
+static void popup(Fl_File_Chooser *fc) {
+ fc->show();
+
+ // deactivate Fl::grab(), because it is incompatible with modal windows
+ Fl_Window* g = Fl::grab();
+ if (g) Fl::grab(0);
+
+ while (fc->shown())
+ Fl::wait();
+
+ if (g) // regrab the previous popup menu, if there was one
+ Fl::grab(g);
+}
+
+
/** \addtogroup group_comdlg
@{ */
@@ -130,11 +146,7 @@ fl_file_chooser(const char *message, // I - Message in titlebar
}
fc->ok_label(current_label);
- fc->show();
-
- while (fc->shown())
- Fl::wait();
-
+ popup(fc);
if (fc->value() && relative) {
fl_filename_relative(retname, sizeof(retname), fc->value());
@@ -171,10 +183,7 @@ fl_dir_chooser(const char *message, // I - Message for titlebar
fc->label(message);
}
- fc->show();
-
- while (fc->shown())
- Fl::wait();
+ popup(fc);
if (fc->value() && relative) {
fl_filename_relative(retname, sizeof(retname), fc->value());