Skip to content

Commit

Permalink
fix: Actively delete opened dialogs after they closed instead of wait…
Browse files Browse the repository at this point in the history
…ing for Qt to delete them when closing the software
  • Loading branch information
SebiAi committed Jan 25, 2024
1 parent d5886b3 commit 18f0765
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,15 @@ void MainWindow::processOpenCompositionDialogAccepted(const OpenCompositionDialo
// Reopen the OpenCompositionDialog
emit this->openFileAction->triggered();
});
connect(msg, &QDialog::finished, msg, &QWidget::deleteLater); // Delete the dialog after it finished
msg->open();

return;
}
catch (const CompositionManager::InvalidLightDataContentException& e)
{
QMessageBox* msg = new QMessageBox(QMessageBox::Critical, "Critical Error", e.what(), QMessageBox::StandardButton::Ok, this->window());
connect(msg, &QDialog::finished, msg, &QWidget::deleteLater); // Delete the dialog after it finished
msg->open();

return;
Expand Down Expand Up @@ -310,6 +312,7 @@ void MainWindow::aboutAction_onTriggered(bool checked)
.append("\n***\nCreator: *Sebastian Aigner aka. SebiAi*\n\nGitHub: ").append(QString("[*%1*](%2)").arg(APPLICATION_GITHUB_REPO_URL, APPLICATION_GITHUB_REPO_URL)),
QMessageBox::StandardButton::Ok, this);
mb->setTextFormat(Qt::TextFormat::MarkdownText);
connect(mb, &QDialog::finished, mb, &QWidget::deleteLater); // Delete the dialog after it finished
mb->open();
}

Expand Down Expand Up @@ -406,6 +409,7 @@ void MainWindow::updateChecker_onUpdateAvailable(const QString &newVersion)
.append("\n\n**You can download it here:** [**Download**]").append(QString("(%1)").arg(APPLICATION_RELEASE_URL.arg(newVersion))),
QMessageBox::StandardButton::Ok, this);
mb->setTextFormat(Qt::TextFormat::MarkdownText);
connect(mb, &QDialog::finished, mb, &QWidget::deleteLater); // Delete the dialog after it finished
mb->open();
}

Expand All @@ -417,6 +421,7 @@ void MainWindow::updateChecker_onUpdateCheckFailed(const QString &errorMessage)
QString("**An error occurred during the update check:**\n\n*%1*\n\n").arg(errorMessage),
QMessageBox::StandardButton::Ok, this);
mb->setTextFormat(Qt::TextFormat::MarkdownText);
connect(mb, &QDialog::finished, mb, &QWidget::deleteLater); // Delete the dialog after it finished
mb->open();
}

Expand All @@ -428,6 +433,7 @@ void MainWindow::updateChecker_noUpdateAvailable()
QString("## No update available\n\n**You are on the latest version of this software!**"),
QMessageBox::StandardButton::Ok, this);
mb->setTextFormat(Qt::TextFormat::MarkdownText);
connect(mb, &QDialog::finished, mb, &QWidget::deleteLater); // Delete the dialog after it finished
mb->open();
}

Expand Down
1 change: 1 addition & 0 deletions src/open_composition_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ void OpenCompositionDialog::buttonBox_onAccepted()
{
// Display error dialog and return
QMessageBox* msg = new QMessageBox(QMessageBox::Icon::Information, "Empty fields", "Please fill out all the required fields.", QMessageBox::StandardButton::Ok, this->window());
connect(msg, &QDialog::finished, msg, &QWidget::deleteLater); // Delete the dialog after it finished
msg->open();
return;
}
Expand Down

0 comments on commit 18f0765

Please sign in to comment.