diff --git a/libgui/src/find-files-dialog.cc b/libgui/src/find-files-dialog.cc --- a/libgui/src/find-files-dialog.cc +++ b/libgui/src/find-files-dialog.cc @@ -204,6 +204,8 @@ namespace octave find_files_dialog::~find_files_dialog (void) { + save_settings (); + delete m_dir_iterator; } diff --git a/libgui/src/main-window.cc b/libgui/src/main-window.cc --- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -323,9 +323,11 @@ namespace octave main_window::~main_window (void) { - // These must be explicitly deleted because they are not - // intentionally not children of main_window. See the comments in - // the functions where they are constructed. + write_settings (); + + // These must be explicitly deleted because they are intentionally + // not children of main_window. See the comments in the functions + // where they are constructed. delete m_release_notes_window; delete m_community_news_window; @@ -1071,17 +1073,6 @@ namespace octave void main_window::prepare_to_exit (void) { - // Find files dialog is constructed dynamically, not at time of main_window - // construction. Connecting it to qApp aboutToQuit signal would have - // caused it to run after gui_settings is deleted. - if (m_find_files_dlg) - m_find_files_dlg->save_settings (); - - if (m_set_path_dlg) - m_set_path_dlg->save_settings (); - - write_settings (); - // No more active dock, otherwise, focus_changed would try to set // the focus to a dock widget that might not exist anymore m_active_dock = nullptr; @@ -2107,28 +2098,6 @@ namespace octave construct_tool_bar (); - // Order is important. Deleting gui_settings must be last. - connect (qApp, &QApplication::aboutToQuit, - m_command_window, &terminal_dock_widget::save_settings); - - connect (qApp, &QApplication::aboutToQuit, - m_history_window, &history_dock_widget::save_settings); - - connect (qApp, &QApplication::aboutToQuit, - m_file_browser_window, &files_dock_widget::save_settings); - - connect (qApp, &QApplication::aboutToQuit, - m_doc_browser_window, &documentation_dock_widget::save_settings); - - connect (qApp, &QApplication::aboutToQuit, - m_workspace_window, &workspace_view::save_settings); - - connect (qApp, &QApplication::aboutToQuit, - m_editor_window, &file_editor_interface::save_settings); - - connect (qApp, &QApplication::aboutToQuit, - m_variable_editor_window, &variable_editor::save_settings); - connect (qApp, &QApplication::aboutToQuit, this, &main_window::prepare_to_exit); diff --git a/libgui/src/octave-dock-widget.cc b/libgui/src/octave-dock-widget.cc --- a/libgui/src/octave-dock-widget.cc +++ b/libgui/src/octave-dock-widget.cc @@ -256,6 +256,11 @@ namespace octave handle_settings (rmgr.get_settings ()); } + octave_dock_widget::~octave_dock_widget (void) + { + save_settings (); + } + void octave_dock_widget::init_window_menu_entry (void) { @@ -431,7 +436,6 @@ namespace octave { emit active_changed (false); set_focus_predecessor (); - save_settings (); QDockWidget::closeEvent (e); } diff --git a/libgui/src/octave-dock-widget.h b/libgui/src/octave-dock-widget.h --- a/libgui/src/octave-dock-widget.h +++ b/libgui/src/octave-dock-widget.h @@ -92,7 +92,7 @@ namespace octave octave_dock_widget (const QString& obj_name, QWidget *p, base_qobject& oct_qobj); - ~octave_dock_widget (void) = default; + ~octave_dock_widget (void); void set_predecessor_widget (octave_dock_widget *prev_widget); diff --git a/libgui/src/octave-qobject.cc b/libgui/src/octave-qobject.cc --- a/libgui/src/octave-qobject.cc +++ b/libgui/src/octave-qobject.cc @@ -306,38 +306,7 @@ namespace octave // deleteLater slot that is called when the m_main_thread issues a // finished signal. - // FIXME: Why are dock widget settings and/or the main window - // configuration not saved correctly if the main window is deleted - // after the dock widgets? - - - // Calling close will cause settings to be saved. - // If m_main_window exists, the widgets are closed by the main window - - if (! m_main_window) - { - if (m_documentation_widget) - m_documentation_widget->close (); - - if (m_file_browser_widget) - m_file_browser_widget->close (); - - if (m_history_widget) - m_history_widget->close (); - - if (m_workspace_widget) - m_workspace_widget->close (); - - if (m_editor_widget) - m_editor_widget->close (); - - if (m_variable_editor_widget) - m_variable_editor_widget->close (); - } - else - { - delete m_main_window; - } + delete m_main_window; delete m_documentation_widget; delete m_file_browser_widget; diff --git a/libgui/src/set-path-dialog.cc b/libgui/src/set-path-dialog.cc --- a/libgui/src/set-path-dialog.cc +++ b/libgui/src/set-path-dialog.cc @@ -174,6 +174,11 @@ namespace octave settings->value(pd_geometry.key).toByteArray()); } + set_path_dialog::~set_path_dialog (void) + { + save_settings (); + } + void set_path_dialog::update_model (void) { set_path_model *m = static_cast (m_path_list->model ()); diff --git a/libgui/src/set-path-dialog.h b/libgui/src/set-path-dialog.h --- a/libgui/src/set-path-dialog.h +++ b/libgui/src/set-path-dialog.h @@ -55,7 +55,7 @@ namespace octave set_path_dialog (QWidget *parent, base_qobject& oct_qobj); - virtual ~set_path_dialog (void) = default; + virtual ~set_path_dialog (void); void save_settings (void);