Fix crash with open windows when switching projects

This commit is contained in:
GriffinR 2020-03-31 12:41:15 -04:00
parent e9210f96aa
commit c28730e834
2 changed files with 13 additions and 0 deletions

View file

@ -216,6 +216,7 @@ private:
bool openRecentProject();
void updateTilesetEditor();
QString getEventGroupFromTabWidget(QWidget *tab);
void closeSupplementaryWindows();
bool isProjectOpen();
};

View file

@ -293,6 +293,7 @@ bool MainWindow::openProject(QString dir) {
projectConfig.setProjectDir(dir);
projectConfig.load();
this->closeSupplementaryWindows();
this->setProjectSpecificUIVisibility();
bool already_open = isProjectOpen() && (editor->project->root == dir);
@ -2410,6 +2411,17 @@ void MainWindow::on_actionRegion_Map_Editor_triggered() {
}
}
void MainWindow::closeSupplementaryWindows() {
if (this->tilesetEditor)
delete this->tilesetEditor;
if (this->regionMapEditor)
delete this->regionMapEditor;
if (this->mapImageExporter)
delete this->mapImageExporter;
if (this->newmapprompt)
delete this->newmapprompt;
}
void MainWindow::closeEvent(QCloseEvent *event) {
if (projectHasUnsavedChanges || editor->map->hasUnsavedChanges()) {
QMessageBox::StandardButton result = QMessageBox::question(