Fix settings window crash on close
This commit is contained in:
parent
7f871efccb
commit
cd1c3fef94
3 changed files with 14 additions and 8 deletions
|
@ -23,6 +23,7 @@ public:
|
||||||
|
|
||||||
static const int eventsTab;
|
static const int eventsTab;
|
||||||
void setTab(int index);
|
void setTab(int index);
|
||||||
|
void closeQuietly();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void reloadProject();
|
void reloadProject();
|
||||||
|
|
|
@ -2905,8 +2905,8 @@ void MainWindow::closeSupplementaryWindows() {
|
||||||
delete this->mapImageExporter;
|
delete this->mapImageExporter;
|
||||||
delete this->newMapPrompt;
|
delete this->newMapPrompt;
|
||||||
delete this->shortcutsEditor;
|
delete this->shortcutsEditor;
|
||||||
delete this->projectSettingsEditor;
|
|
||||||
delete this->customScriptsEditor;
|
delete this->customScriptsEditor;
|
||||||
|
if (this->projectSettingsEditor) this->projectSettingsEditor->closeQuietly();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
|
|
|
@ -639,18 +639,24 @@ void ProjectSettingsEditor::dialogButtonClicked(QAbstractButton *button) {
|
||||||
if (buttonRole == QDialogButtonBox::AcceptRole) {
|
if (buttonRole == QDialogButtonBox::AcceptRole) {
|
||||||
// "OK" button
|
// "OK" button
|
||||||
this->save();
|
this->save();
|
||||||
close();
|
this->close();
|
||||||
} else if (buttonRole == QDialogButtonBox::RejectRole) {
|
} else if (buttonRole == QDialogButtonBox::RejectRole) {
|
||||||
// "Cancel" button
|
// "Cancel" button
|
||||||
if (!this->promptSaveChanges())
|
this->close();
|
||||||
return;
|
|
||||||
close();
|
|
||||||
} else if (buttonRole == QDialogButtonBox::ResetRole) {
|
} else if (buttonRole == QDialogButtonBox::ResetRole) {
|
||||||
// "Restore Defaults" button
|
// "Restore Defaults" button
|
||||||
this->promptRestoreDefaults();
|
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) {
|
void ProjectSettingsEditor::closeEvent(QCloseEvent* event) {
|
||||||
if (!this->promptSaveChanges()) {
|
if (!this->promptSaveChanges()) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
|
@ -664,9 +670,8 @@ void ProjectSettingsEditor::closeEvent(QCloseEvent* event) {
|
||||||
|
|
||||||
if (this->projectNeedsReload) {
|
if (this->projectNeedsReload) {
|
||||||
// Note: Declining this prompt with changes that need a reload may cause problems
|
// 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){
|
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
|
|
||||||
emit this->reloadProject();
|
emit this->reloadProject();
|
||||||
}
|
}
|
||||||
}
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue