diff --git a/src/app/application.cpp b/src/app/application.cpp index aeee2c7cd..3b1ff7b1a 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #ifndef DISABLE_GUI #include "gui/guiiconprovider.h" @@ -547,11 +548,9 @@ void Application::cleanup() #ifndef DISABLE_GUI #ifdef Q_OS_WIN // cleanup() can be called multiple times during shutdown. We only need it once. - static bool alreadyDone = false; - - if (alreadyDone) + static QAtomicInt alreadyDone; + if (!alreadyDone.testAndSetAcquire(0, 1)) return; - alreadyDone = true; #endif // Q_OS_WIN // Hide the window and not leave it on screen as diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 4306d7c68..25c22b1b7 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -678,12 +678,12 @@ void MainWindow::cleanup() #if (defined(Q_OS_WIN) || defined(Q_OS_MAC)) m_programUpdateTimer->stop(); #endif - delete m_searchFilter; + delete m_searchFilterAction; - delete m_tabs; // this seems enough to also delete all contained widgets - delete m_statusBar; - delete m_pwr; - delete m_toolbarMenu; + + // remove all child widgets + while (QWidget *w = findChild()) + delete w; } void MainWindow::readSettings()