changeset 19726:b30cd22e6471

fix reappearing closed editor tabs at next restart (bug #44219) * file-editor.cc (constructor): init flag for closing-check; (destructor): call check_closing only if this check is not yet done; (check_closing): set flag in order to indicate that check is done * file-editor.h: new flag
author Torsten <ttl@justmail.de>
date Tue, 10 Feb 2015 22:27:29 +0100
parents 480f0fc56bbf
children 05b40890bbb2
files libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Tue Feb 10 02:37:29 2015 -0600
+++ b/libgui/src/m-editor/file-editor.cc	Tue Feb 10 22:27:29 2015 +0100
@@ -54,6 +54,8 @@
   // files will change ced accordingly.
   ced = QDir::currentPath ();
 
+  _check_closing_done = false;  // init flag for closing process
+
   construct ();
 
   setVisible (false);
@@ -64,9 +66,13 @@
 file_editor::~file_editor (void)
 {
   // Close open tabs, if existing. In this case app closing must be
-  // initiated by octave. All tabs will be definetly closed and the
+  // initiated by octave since check_closing was already done if the gui
+  // initiated the closing. All tabs will be definetly closed and the
   // user can not cancel exiting (close state -1)
-  if (_tab_widget->count ())
+  // We have to prevent that on case of gui-closing this check is done
+  // a second time resulting in an empty file list (tabs closed) for the
+  // the next start, that is what _check_closing_done is for
+  if (! _check_closing_done)
     check_closing (-1);
 
   if (_mru_file_menu)
@@ -109,6 +115,8 @@
     }
 
   // Here, we really want to exit and all tabs are closed
+  _check_closing_done = true;  // check is already done, prevent a second check
+                               // which would store an empty file list
   return true;
 }
 
--- a/libgui/src/m-editor/file-editor.h	Tue Feb 10 02:37:29 2015 -0600
+++ b/libgui/src/m-editor/file-editor.h	Tue Feb 10 22:27:29 2015 +0100
@@ -351,6 +351,8 @@
   QMenu *_mru_file_menu;
   QAction *_mru_file_actions[MaxMRUFiles];
   QStringList _mru_files;
+
+  bool _check_closing_done;
 };
 
 #endif // FILEEDITORMDISUBWINDOW_H