desktop: make MainWindow a "global object"

Thus, we don't have to delete it explicitly on exit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-03-13 18:45:50 +01:00 committed by Dirk Hohndel
parent 16aa761e86
commit ee9344eccf
2 changed files with 2 additions and 5 deletions

View file

@ -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),

View file

@ -58,16 +58,13 @@ void init_ui()
#ifndef SUBSURFACE_MOBILE
register_qml_types(NULL);
MainWindow *window = new MainWindow();
MainWindow *window = make_global<MainWindow>();
window->setTitle();
#endif // SUBSURFACE_MOBILE
}
void exit_ui()
{
#ifndef SUBSURFACE_MOBILE
delete MainWindow::instance();
#endif // SUBSURFACE_MOBILE
free_globals();
free((void *)existing_filename);
}