aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-05-25 23:08:18 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-05-26 09:21:46 -0700
commitd21d42b69117aae04b68ecc9cc2139e034bde146 (patch)
tree6bb81d66565de33cb2de09eebc8924e9caf62c68 /desktop-widgets
parent0de862971e98a6db88562b1e3424ee9cd3024679 (diff)
downloadsubsurface-d21d42b69117aae04b68ecc9cc2139e034bde146.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/mainwindow.cpp22
1 files 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;
}
}