From 71ff235c78fcaff20417de3895810a9abfb28d56 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 14 Jun 2026 03:30:19 -0400 Subject: [PATCH] Fix duplicate Locations appearing in map list --- CHANGELOG.md | 1 + src/ui/maplistmodels.cpp | 16 ++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 617d6d04..6f6eb4d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp - Fix some menu items under `Tools` not being disabled when their corresponding button is disabled. - Fix the map list search bar stealing keyboard focus whenever a map layout was opened. - Disallow creating prefabs with no metatiles. +- Fix new `Location` names created via the `Header` tab temporarily appearing twice after saving. ## [6.3.1] - 2026-04-12 ### Added diff --git a/src/ui/maplistmodels.cpp b/src/ui/maplistmodels.cpp index 987fded6..fb597780 100644 --- a/src/ui/maplistmodels.cpp +++ b/src/ui/maplistmodels.cpp @@ -128,16 +128,8 @@ QStandardItem *MapListModel::insertMapItem(const QString &mapName, const QString return nullptr; QStandardItem *map = createMapItem(mapName); - - QStandardItem *folder = this->mapFolderItems[folderName]; - if (!folder) { - // Folder doesn't exist yet, add it. - folder = insertMapFolderItem(folderName); - } - // If folder is still nullptr here it's because we failed to create it. - if (folder) { - folder->appendRow(map); - } + QStandardItem *folder = insertMapFolderItem(folderName); + if (folder) folder->appendRow(map); return map; } @@ -145,6 +137,10 @@ QStandardItem *MapListModel::insertMapFolderItem(const QString &folderName) { if (folderName.isEmpty()) return nullptr; + // If the folder has already been inserted, don't insert it again. + auto search = this->mapFolderItems.constFind(folderName); + if (search != this->mapFolderItems.constEnd()) return search.value(); + QStandardItem *item = createMapFolderItem(folderName); this->root->appendRow(item); return item;