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>
This commit is contained in:
Berthold Stoeger 2018-05-25 23:08:18 +02:00 committed by Dirk Hohndel
parent 0de862971e
commit d21d42b691

View file

@ -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;
}
}