From 3467e06199be0af83f642ebeb57c3292e7283339 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 9 Mar 2016 16:44:41 -0800 Subject: [PATCH] Fix bugs in mapping model update --- .../src/AssetMappingsScriptingInterface.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libraries/script-engine/src/AssetMappingsScriptingInterface.cpp b/libraries/script-engine/src/AssetMappingsScriptingInterface.cpp index c5b165d7f6..8dc40b0df1 100644 --- a/libraries/script-engine/src/AssetMappingsScriptingInterface.cpp +++ b/libraries/script-engine/src/AssetMappingsScriptingInterface.cpp @@ -173,15 +173,24 @@ void AssetMappingModel::refresh() { Q_ASSERT(fullPath == path); } + + // Remove folders from list + auto it = existingPaths.begin(); + while (it != existingPaths.end()) { + auto item = _pathToItemMap[*it]; + if (item->data(Qt::UserRole + 1).toBool()) { + it = existingPaths.erase(it); + } else { + ++it; + } + } + for (auto& path : existingPaths) { Q_ASSERT(_pathToItemMap.contains(path)); - auto item = _pathToItemMap[path]; - if (item->data(Qt::UserRole + 1).toBool()) { - continue; - } - qDebug() << "removing existing: " << path; + auto item = _pathToItemMap[path]; + while (item) { // During each iteration, delete item QStandardItem* nextItem = nullptr;