diff --git a/include/mainwindow.h b/include/mainwindow.h index 9113e227..27fe541c 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -216,6 +216,7 @@ private: bool openRecentProject(); void updateTilesetEditor(); QString getEventGroupFromTabWidget(QWidget *tab); + void closeSupplementaryWindows(); bool isProjectOpen(); }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 595f4606..a0fcd6d0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(