From afb157beb3c3cecd3fd1ad7de4ff2973dcc86295 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 6 Jun 2020 09:51:36 -0400 Subject: [PATCH] Assign editor->map to nullptr after clearing map cache --- include/mainwindow.h | 1 + include/project.h | 1 + src/mainwindow.cpp | 5 +++++ src/project.cpp | 1 + 4 files changed, 8 insertions(+) diff --git a/include/mainwindow.h b/include/mainwindow.h index 4fb4cc87..33573857 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -128,6 +128,7 @@ private slots: void onWildMonDataChanged(); void openNewMapPopupWindow(int, QVariant); void onNewMapCreated(); + void onMapCacheCleared(); void on_action_NewMap_triggered(); void on_actionNew_Tileset_triggered(); diff --git a/include/project.h b/include/project.h index c8f722d2..4b584250 100644 --- a/include/project.h +++ b/include/project.h @@ -219,6 +219,7 @@ private: signals: void reloadProject(); void uncheckMonitorFilesAction(); + void mapCacheCleared(); }; #endif // PROJECT_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f42323f6..61125117 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -326,6 +326,7 @@ bool MainWindow::openProject(QString dir) { editor->closeProject(); editor->project = new Project(this); QObject::connect(editor->project, SIGNAL(reloadProject()), this, SLOT(on_action_Reload_Project_triggered())); + QObject::connect(editor->project, SIGNAL(mapCacheCleared()), this, SLOT(onMapCacheCleared())); QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this] () { ui->actionMonitor_Project_Files->setChecked(false); }); on_actionMonitor_Project_Files_triggered(porymapConfig.getMonitorFiles()); editor->project->set_root(dir); @@ -2217,6 +2218,10 @@ void MainWindow::onMapNeedsRedrawing() { redrawMapScene(); } +void MainWindow::onMapCacheCleared() { + editor->map = nullptr; +} + void MainWindow::onTilesetsSaved(QString primaryTilesetLabel, QString secondaryTilesetLabel) { this->editor->updatePrimaryTileset(primaryTilesetLabel, true); this->editor->updateSecondaryTileset(secondaryTilesetLabel, true); diff --git a/src/project.cpp b/src/project.cpp index 52794047..5600bc54 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -143,6 +143,7 @@ void Project::clearMapCache() { Map *map = mapCache->take(mapName); if (map) delete map; } + emit mapCacheCleared(); } void Project::clearTilesetCache() {