From a4fc2bcb307069c2eb17b57d405140a633fe7bbe Mon Sep 17 00:00:00 2001 From: BigBahss Date: Thu, 18 Feb 2021 19:37:55 -0500 Subject: [PATCH] Fix crash when creating new map --- src/mainwindow.cpp | 5 +++-- src/project.cpp | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f4d7599e..843df201 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1105,10 +1105,10 @@ void MainWindow::onAddNewMapToLayoutClick(QAction* triggeredAction) void MainWindow::onNewMapCreated() { QString newMapName = this->newmapprompt->map->name; int newMapGroup = this->newmapprompt->group; - Map *newMap_ = this->newmapprompt->map; + Map *newMap = this->newmapprompt->map; bool existingLayout = this->newmapprompt->existingLayout; - Map *newMap = editor->project->addNewMapToGroup(newMapName, newMapGroup, newMap_, existingLayout); + newMap = editor->project->addNewMapToGroup(newMapName, newMapGroup, newMap, existingLayout); logInfo(QString("Created a new map named %1.").arg(newMapName)); @@ -1132,6 +1132,7 @@ void MainWindow::onNewMapCreated() { } disconnect(this->newmapprompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated); + delete newMap; } void MainWindow::openNewMapPopupWindow(int type, QVariant data) { diff --git a/src/project.cpp b/src/project.cpp index aea7e0c4..9d48df55 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1856,7 +1856,6 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap, bool loadMapTilesets(newMap); setNewMapEvents(newMap); setNewMapConnections(newMap); - mapCache.insert(mapName, newMap); return newMap; }