From eebda637fae8559d69d1d80818288abf407c7dc9 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 2 Feb 2015 17:55:22 +0000 Subject: 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 --- src/fl_file_dir.cxx | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src') 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()); -- cgit v1.2.3