changeset 29374:34097a2f1f60

maint: merge stable to default.
author Rik <rik@octave.org>
date Wed, 17 Feb 2021 13:14:55 -0800
parents d35ed8538d69 (current diff) 23a5daf1e809 (diff)
children 8f6a2f5e5934
files libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h scripts/sparse/bicgstab.m scripts/sparse/cgs.m
diffstat 4 files changed, 50 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Sun Feb 14 10:28:13 2021 -0800
+++ b/libgui/src/m-editor/file-editor.cc	Wed Feb 17 13:14:55 2021 -0800
@@ -408,6 +408,48 @@
       }
   }
 
+  // Save open files for restoring in next session
+  // (even if last session will not be restored next time)
+  // together with encoding and the tab index
+  void file_editor::save_session (void)
+  {
+    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+    gui_settings *settings = rmgr.get_settings ();
+
+    QStringList fetFileNames;
+    QStringList fet_encodings;
+    QStringList fet_index;
+    QStringList fet_lines;
+
+    std::list<file_editor_tab *> editor_tab_lst = m_tab_widget->tab_list ();
+
+    for (auto editor_tab : editor_tab_lst)
+      {
+        QString file_name = editor_tab->file_name ();
+
+        // Don't append unnamed files.
+
+        if (! file_name.isEmpty ())
+          {
+            fetFileNames.append (file_name);
+            fet_encodings.append (editor_tab->encoding ());
+
+            QString index;
+            fet_index.append (index.setNum (m_tab_widget->indexOf (editor_tab)));
+
+            int l, c;
+            editor_tab->qsci_edit_area ()->getCursorPosition (&l, &c);
+            fet_lines.append (index.setNum (l + 1));
+          }
+      }
+
+    settings->setValue (ed_session_names.key, fetFileNames);
+    settings->setValue (ed_session_enc.key, fet_encodings);
+    settings->setValue (ed_session_ind.key, fet_index);
+    settings->setValue (ed_session_lines.key, fet_lines);
+    settings->sync ();
+  }
+
   bool file_editor::check_closing (void)
   {
     // When the application or the editor is closing and the user wants to
@@ -417,6 +459,10 @@
     // Therefore, saving the session for restoring at next start is not done
     // before the application is definitely closing.
 
+    // Save the session. Even is closing is cancelled, this would be
+    // overwritten by the next attempt to close the editor
+    save_session ();
+
     std::list<file_editor_tab *> fe_tab_lst = m_tab_widget->tab_list ();
     m_number_of_tabs = fe_tab_lst.size ();
 
@@ -466,47 +512,6 @@
 
     // Here, the application or the editor will be closed -> store the session
 
-    // Save open files for restoring in next session; this only is possible
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-    gui_settings *settings = rmgr.get_settings ();
-
-    // save filenames (even if last session will not be restored next time)
-    // together with encoding and the tab index
-    QStringList fetFileNames;
-    QStringList fet_encodings;
-    QStringList fet_index;
-    QStringList fet_lines;
-
-    // save all open tabs before they are definitely closed
-
-    std::list<file_editor_tab *> editor_tab_lst = m_tab_widget->tab_list ();
-
-    for (auto editor_tab : editor_tab_lst)
-      {
-        QString file_name = editor_tab->file_name ();
-
-        // Don't append unnamed files.
-
-        if (! file_name.isEmpty ())
-          {
-            fetFileNames.append (file_name);
-            fet_encodings.append (editor_tab->encoding ());
-
-            QString index;
-            fet_index.append (index.setNum (m_tab_widget->indexOf (editor_tab)));
-
-            int l, c;
-            editor_tab->qsci_edit_area ()->getCursorPosition (&l, &c);
-            fet_lines.append (index.setNum (l + 1));
-          }
-      }
-
-    settings->setValue (ed_session_names.key, fetFileNames);
-    settings->setValue (ed_session_enc.key, fet_encodings);
-    settings->setValue (ed_session_ind.key, fet_index);
-    settings->setValue (ed_session_lines.key, fet_lines);
-    settings->sync ();
-
     // Take care of the find dialog
     if (m_find_dialog)
       m_find_dialog->close ();
@@ -517,6 +522,7 @@
     // hidden before, this state has to be restored afterwards.
     bool vis = isVisible ();
 
+    std::list<file_editor_tab *> editor_tab_lst = m_tab_widget->tab_list ();
     for (auto editor_tab : editor_tab_lst)
       delete editor_tab;
 
--- a/libgui/src/m-editor/file-editor.h	Sun Feb 14 10:28:13 2021 -0800
+++ b/libgui/src/m-editor/file-editor.h	Wed Feb 17 13:14:55 2021 -0800
@@ -182,6 +182,7 @@
     void activate (void);
     void set_focus (QWidget *fet);
     void enable_menu_shortcuts (bool);
+    void save_session (void);
     bool check_closing (void);
     void handle_tab_ready_to_close (void);
 
--- a/scripts/sparse/bicgstab.m	Sun Feb 14 10:28:13 2021 -0800
+++ b/scripts/sparse/bicgstab.m	Wed Feb 17 13:14:55 2021 -0800
@@ -224,7 +224,7 @@
       printf ("returned an all zero solution without iterating.\n")
     endif
     x_min = zeros (numel (b), 1);
-    iter_ min = 0;
+    iter_min = 0;
     flag = 0;
     resvec = 0;
     relres = 0;
--- a/scripts/sparse/cgs.m	Sun Feb 14 10:28:13 2021 -0800
+++ b/scripts/sparse/cgs.m	Wed Feb 17 13:14:55 2021 -0800
@@ -208,7 +208,7 @@
       printf ("returned an all zero solution without iterating.\n")
     endif
     x_min = zeros (numel (b), 1);
-    iter_ min = 0;
+    iter_min = 0;
     flag = 0;
     resvec = 0;
     relres = 0;