# HG changeset patch # User Torsten # Date 1402943428 -7200 # Node ID 08d7dbd728bc15f5db4afaa08e90e2d413de66fd # Parent 0e6f7b5f65561cb97f0dae82260051b9abf98359 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 diff -r 0e6f7b5f6556 -r 08d7dbd728bc libgui/src/m-editor/file-editor-tab.cc --- 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 { diff -r 0e6f7b5f6556 -r 08d7dbd728bc libgui/src/m-editor/file-editor-tab.h --- 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;