From 76152906bea3c76281d63cf6cbb774a5f9d635b2 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 10 Mar 2016 15:37:38 -0800 Subject: [PATCH 1/3] Fix crash bug in asset manager --- .../src/AssetMappingsScriptingInterface.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/script-engine/src/AssetMappingsScriptingInterface.cpp b/libraries/script-engine/src/AssetMappingsScriptingInterface.cpp index ee8deb4056..77cc435fb8 100644 --- a/libraries/script-engine/src/AssetMappingsScriptingInterface.cpp +++ b/libraries/script-engine/src/AssetMappingsScriptingInterface.cpp @@ -155,13 +155,13 @@ void AssetMappingModel::refresh() { auto it = _pathToItemMap.find(fullPath); if (it == _pathToItemMap.end()) { - qDebug() << "prefix not found: " << fullPath; auto item = new QStandardItem(parts[i]); bool isFolder = i < length - 1; item->setData(isFolder ? fullPath + "/" : fullPath, Qt::UserRole); item->setData(isFolder, Qt::UserRole + 1); item->setData(parts[i], Qt::UserRole + 2); item->setData("atp:" + fullPath, Qt::UserRole + 3); + item->setData(fullPath, Qt::UserRole + 4); if (lastItem) { lastItem->setChild(lastItem->rowCount(), 0, item); } else { @@ -182,6 +182,7 @@ void AssetMappingModel::refresh() { // Remove folders from list auto it = existingPaths.begin(); while (it != existingPaths.end()) { + Q_ASSERT(_pathToItemMap.contains(*it)); auto item = _pathToItemMap[*it]; if (item->data(Qt::UserRole + 1).toBool()) { it = existingPaths.erase(it); @@ -192,7 +193,6 @@ void AssetMappingModel::refresh() { for (auto& path : existingPaths) { Q_ASSERT(_pathToItemMap.contains(path)); - qDebug() << "removing existing: " << path; auto item = _pathToItemMap[path]; @@ -200,6 +200,7 @@ void AssetMappingModel::refresh() { // During each iteration, delete item QStandardItem* nextItem = nullptr; + auto fullPath = item->data(Qt::UserRole + 4).toString(); auto parent = item->parent(); if (parent) { parent->removeRow(item->row()); @@ -210,15 +211,15 @@ void AssetMappingModel::refresh() { nextItem = parent; } } else { - removeRow(item->row()); + auto removed = removeRow(item->row()); + Q_ASSERT(removed); } - _pathToItemMap.remove(path); - //delete item; + Q_ASSERT(_pathToItemMap.contains(fullPath)); + _pathToItemMap.remove(fullPath); item = nextItem; } - //removeitem->index(); } } else { emit errorGettingMappings(uint8_t(request->getError())); From 76ed16314a4f6b302def5b42d7f270ea37557e2c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 10 Mar 2016 15:38:20 -0800 Subject: [PATCH 2/3] Add prepended slash on rename if missing --- interface/resources/qml/AssetServer.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index c69af702fb..8819d1100c 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -73,6 +73,10 @@ Window { function doRenameFile(oldPath, newPath) { console.log("Renaming " + oldPath + " to " + newPath); + if (newPath[0] != "/") { + newPath = "/" + newPath; + } + Assets.renameMapping(oldPath, newPath, function(err) { if (err) { console.log("Error renaming: ", oldPath, "=>", newPath, " - error ", err); From ad0fb18d81dad2323d0a2b411132d581baf0ee0c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 10 Mar 2016 16:02:41 -0800 Subject: [PATCH 3/3] Add / to beginning of mapping on upload if missing --- interface/src/scripting/AssetMappingsScriptingInterface.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/src/scripting/AssetMappingsScriptingInterface.cpp b/interface/src/scripting/AssetMappingsScriptingInterface.cpp index 11a14c7686..6ac60ccbdf 100644 --- a/interface/src/scripting/AssetMappingsScriptingInterface.cpp +++ b/interface/src/scripting/AssetMappingsScriptingInterface.cpp @@ -88,6 +88,9 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, return; } mapping = result.toString(); + if (mapping[0] != '/') { + mapping = "/" + mapping; + } // Check for override if (isKnownMapping(mapping)) {