From ee9344eccf152aca8352b644a24da7dd73db7174 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 13 Mar 2022 18:45:50 +0100 Subject: [PATCH] desktop: make MainWindow a "global object" Thus, we don't have to delete it explicitly on exit. Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 2 +- subsurface-helper.cpp | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index d1d5260c9..310148003 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -111,7 +111,7 @@ extern "C" void showErrorFromC(char *buf) emit MainWindow::instance()->showError(error); } -MainWindow::MainWindow() : QMainWindow(), +MainWindow::MainWindow() : appState((ApplicationState)-1), // Invalid state actionNextDive(nullptr), actionPreviousDive(nullptr), diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index e0d8f18d6..375d6e84a 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -58,16 +58,13 @@ void init_ui() #ifndef SUBSURFACE_MOBILE register_qml_types(NULL); - MainWindow *window = new MainWindow(); + MainWindow *window = make_global(); window->setTitle(); #endif // SUBSURFACE_MOBILE } void exit_ui() { -#ifndef SUBSURFACE_MOBILE - delete MainWindow::instance(); -#endif // SUBSURFACE_MOBILE free_globals(); free((void *)existing_filename); }