diff --git a/include/ui/projectsettingseditor.h b/include/ui/projectsettingseditor.h index 73d0ecd4..7ebf544b 100644 --- a/include/ui/projectsettingseditor.h +++ b/include/ui/projectsettingseditor.h @@ -23,6 +23,7 @@ public: static const int eventsTab; void setTab(int index); + void closeQuietly(); signals: void reloadProject(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5b47526b..8ac833ed 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2905,8 +2905,8 @@ void MainWindow::closeSupplementaryWindows() { delete this->mapImageExporter; delete this->newMapPrompt; delete this->shortcutsEditor; - delete this->projectSettingsEditor; delete this->customScriptsEditor; + if (this->projectSettingsEditor) this->projectSettingsEditor->closeQuietly(); } void MainWindow::closeEvent(QCloseEvent *event) { diff --git a/src/ui/projectsettingseditor.cpp b/src/ui/projectsettingseditor.cpp index 2d9a31ac..5fae58aa 100644 --- a/src/ui/projectsettingseditor.cpp +++ b/src/ui/projectsettingseditor.cpp @@ -639,18 +639,24 @@ void ProjectSettingsEditor::dialogButtonClicked(QAbstractButton *button) { if (buttonRole == QDialogButtonBox::AcceptRole) { // "OK" button this->save(); - close(); + this->close(); } else if (buttonRole == QDialogButtonBox::RejectRole) { // "Cancel" button - if (!this->promptSaveChanges()) - return; - close(); + this->close(); } else if (buttonRole == QDialogButtonBox::ResetRole) { // "Restore Defaults" button this->promptRestoreDefaults(); } } +// Close event triggered by a project reload. User doesn't need any prompts, just close the window. +void ProjectSettingsEditor::closeQuietly() { + // Turn off flags that trigger prompts + this->hasUnsavedChanges = false; + this->projectNeedsReload = false; + this->close(); +} + void ProjectSettingsEditor::closeEvent(QCloseEvent* event) { if (!this->promptSaveChanges()) { event->ignore(); @@ -664,9 +670,8 @@ void ProjectSettingsEditor::closeEvent(QCloseEvent* event) { if (this->projectNeedsReload) { // Note: Declining this prompt with changes that need a reload may cause problems - if (this->prompt("Settings changed, reload project to apply changes?") == QMessageBox::Yes){ - // Reloading the project will destroy this window, no other work should happen after this signal is emitted + if (this->prompt("Settings changed, reload project to apply changes?") == QMessageBox::Yes) emit this->reloadProject(); - } } + QMainWindow::closeEvent(event); }