From d21d42b69117aae04b68ecc9cc2139e034bde146 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 25 May 2018 23:08:18 +0200 Subject: Cleanup: remove three instances of deleteLater() in mainwindow.cpp deleteLater() can be dangerous. Remove where not necessary. Analysis: 1) `helpView` was a pointer which was initialized on demand. close() and deleteLater() were called on closure of the main window. Firstly, there's no point in calling deleteLater(), because no references to helpView are used later on. Secondly, the deletion (and closing) can be done automatically in the destructor, by passing `this` as parent object. 2) `survey`: pretty much the same situation. But here, `this` was already passed as parent object. 3) `progressDialog` is a global (not thread safe!) pointer. The object is deleted after use. There is no point in using deleteLater(), because the callers are not active after hideProgressBar(), which is the place were the deleteLater() call was found. Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 883b81d23..94c319a4b 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1354,18 +1354,16 @@ void MainWindow::on_action_Check_for_Updates_triggered() void MainWindow::on_actionUserManual_triggered() { #ifndef NO_USERMANUAL - if (!helpView) { - helpView = new UserManual(); - } + if (!helpView) + helpView = new UserManual(this); helpView->show(); #endif } void MainWindow::on_actionUserSurvey_triggered() { - if(!survey) { + if(!survey) survey = new UserSurvey(this); - } survey->show(); } @@ -1561,18 +1559,6 @@ void MainWindow::closeEvent(QCloseEvent *event) return; } -#ifndef NO_USERMANUAL - if (helpView && helpView->isVisible()) { - helpView->close(); - helpView->deleteLater(); - } -#endif - - if (survey && survey->isVisible()) { - survey->close(); - survey->deleteLater(); - } - if (unsaved_changes() && (askSaveChanges() == false)) { event->ignore(); return; @@ -2070,7 +2056,7 @@ void MainWindow::hideProgressBar() { if (progressDialog) { progressDialog->setValue(100); - progressDialog->deleteLater(); + delete progressDialog; progressDialog = NULL; } } -- cgit v1.2.3-70-g09d2