Assign editor->map to nullptr after clearing map cache

This commit is contained in:
GriffinR 2020-06-06 09:51:36 -04:00 committed by huderlem
parent c382190e8b
commit afb157beb3
4 changed files with 8 additions and 0 deletions

View file

@ -128,6 +128,7 @@ private slots:
void onWildMonDataChanged(); void onWildMonDataChanged();
void openNewMapPopupWindow(int, QVariant); void openNewMapPopupWindow(int, QVariant);
void onNewMapCreated(); void onNewMapCreated();
void onMapCacheCleared();
void on_action_NewMap_triggered(); void on_action_NewMap_triggered();
void on_actionNew_Tileset_triggered(); void on_actionNew_Tileset_triggered();

View file

@ -219,6 +219,7 @@ private:
signals: signals:
void reloadProject(); void reloadProject();
void uncheckMonitorFilesAction(); void uncheckMonitorFilesAction();
void mapCacheCleared();
}; };
#endif // PROJECT_H #endif // PROJECT_H

View file

@ -326,6 +326,7 @@ bool MainWindow::openProject(QString dir) {
editor->closeProject(); editor->closeProject();
editor->project = new Project(this); editor->project = new Project(this);
QObject::connect(editor->project, SIGNAL(reloadProject()), this, SLOT(on_action_Reload_Project_triggered())); 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); }); QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this] () { ui->actionMonitor_Project_Files->setChecked(false); });
on_actionMonitor_Project_Files_triggered(porymapConfig.getMonitorFiles()); on_actionMonitor_Project_Files_triggered(porymapConfig.getMonitorFiles());
editor->project->set_root(dir); editor->project->set_root(dir);
@ -2217,6 +2218,10 @@ void MainWindow::onMapNeedsRedrawing() {
redrawMapScene(); redrawMapScene();
} }
void MainWindow::onMapCacheCleared() {
editor->map = nullptr;
}
void MainWindow::onTilesetsSaved(QString primaryTilesetLabel, QString secondaryTilesetLabel) { void MainWindow::onTilesetsSaved(QString primaryTilesetLabel, QString secondaryTilesetLabel) {
this->editor->updatePrimaryTileset(primaryTilesetLabel, true); this->editor->updatePrimaryTileset(primaryTilesetLabel, true);
this->editor->updateSecondaryTileset(secondaryTilesetLabel, true); this->editor->updateSecondaryTileset(secondaryTilesetLabel, true);

View file

@ -143,6 +143,7 @@ void Project::clearMapCache() {
Map *map = mapCache->take(mapName); Map *map = mapCache->take(mapName);
if (map) delete map; if (map) delete map;
} }
emit mapCacheCleared();
} }
void Project::clearTilesetCache() { void Project::clearTilesetCache() {