changeset 18871:08d7dbd728bc gui-release

save a new file before trying to run it from the editor (bug #42571) * file-editor-tab.h: new flag for modal/modeless file dialogs * file-editor-tab.cc (constructor): iniitalize new flag to its default value, (run_file): set dialogs to modeless before saving the file preventing running the file before saving is complete, (show_dialog): set mode of dialog corresponding to the new flag
author Torsten <ttl@justmail.de>
date Mon, 16 Jun 2014 20:30:28 +0200
parents 0e6f7b5f6556
children b43157d085ba
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Mon Jun 16 17:40:53 2014 +0200
+++ b/libgui/src/m-editor/file-editor-tab.cc	Mon Jun 16 20:30:28 2014 +0200
@@ -69,6 +69,7 @@
   _lexer_apis = 0;
   _app_closing = false;
   _is_octave_file = true;
+  _modal_dialog = false;
 
   // Make sure there is a slash at the end of the directory name
   // for identification when saved later.
@@ -573,7 +574,11 @@
     return;
 
   if (_edit_area->isModified ())
-    save_file (_file_name);
+    {
+      _modal_dialog = true;    // force modal dialog if the file is a new one
+      save_file (_file_name);  // save file dialog
+      _modal_dialog = false;   // back to non-modal dialogs
+    }
 
   QFileInfo info (_file_name);
   emit run_file_signal (info);
@@ -1077,12 +1082,12 @@
 }
 
 // show_dialog: shows a modal or non modal dialog depeding on the closing
-//              of the app
+//              of the app and the flag _modal_dialog
 void
 file_editor_tab::show_dialog (QDialog *dlg)
 {
   dlg->setAttribute (Qt::WA_DeleteOnClose);
-  if (_app_closing)
+  if (_app_closing | _modal_dialog)
     dlg->exec ();
   else
     {
--- a/libgui/src/m-editor/file-editor-tab.h	Mon Jun 16 17:40:53 2014 +0200
+++ b/libgui/src/m-editor/file-editor-tab.h	Mon Jun 16 20:30:28 2014 +0200
@@ -223,6 +223,7 @@
   bool _copy_available;
   bool _app_closing;
   bool _is_octave_file;
+  bool _modal_dialog;
 
   QFileSystemWatcher _file_system_watcher;