# # # patch "src/model/Inventory.cpp" # from [db9f63fec8fdfb7ba5627df47cc5486b37c6e131] # to [77707a27c5223e3bbca06d355ab102690e7bdbb4] # ============================================================ --- src/model/Inventory.cpp db9f63fec8fdfb7ba5627df47cc5486b37c6e131 +++ src/model/Inventory.cpp 77707a27c5223e3bbca06d355ab102690e7bdbb4 @@ -107,12 +107,21 @@ void Inventory::processTaskResult(const // user errors if (task.getReturnCode() == 2) { - // if the path we've silently queried became unknown, - // just remove it from the model + // if the path we've silently queried became unknown (i.e. was removed), + // remove it from the model. Note however that automate inventory does + // not tell us if the node exists on the filesystem - in this case we + // want to _keep_ the node because otherwise people won't be able to + // add unknown paths later on... if (output.indexOf("unknown path") != -1 && itemMap.contains(queriedPath)) { - D(QString("removing lost %1").arg(queriedPath)); + if (QFile::exists(workspacePath + "/" + itemMap[queriedPath]->getPath())) + { + D(QString("keeping existing unknown node %1").arg(queriedPath)); + return; + } + + D(QString("clean out removed node %1").arg(queriedPath)); InventoryItem * oldItem = itemMap.value(queriedPath); ModelItem * oldParent = oldItem->parent(); int row = oldItem->row(); @@ -320,11 +329,14 @@ void Inventory::insertRowsRecursive(Mode I(children.size() > 0); // - // ensure that old rows get deleted at first + // ensure that all old rows get deleted at first (and ensure that each + // item is only processed once...) // - foreach (ModelItem * item, children) + QSet oldChildren = QSet::fromList(children); + oldChildren.unite(QSet::fromList(parentItem->getChildren())); + foreach (ModelItem * item, oldChildren) { - InventoryItem * invitem = dynamic_cast(item); + InventoryItem * invitem = qobject_cast(item); if (!invitem) continue; QString path = invitem->getPath();