# # # patch "src/model/Inventory.cpp" # from [0ec28beef2098f8491fc4d8249cc0ae970d84feb] # to [792f0527f9627c2fc2b68d5ebc28b0b846ae6db4] # ============================================================ --- src/model/Inventory.cpp 0ec28beef2098f8491fc4d8249cc0ae970d84feb +++ src/model/Inventory.cpp 792f0527f9627c2fc2b68d5ebc28b0b846ae6db4 @@ -335,18 +335,26 @@ void Inventory::insertRowsRecursive(Mode // ensure that all old rows get deleted at first (and ensure that each // item is only processed once...) // - foreach (ModelItem * item, children) + InventoryItem * newInventoryParent = qobject_cast(parentItem); + if (newInventoryParent) { - InventoryItem * invitem = qobject_cast(item); - if (!invitem) continue; + InventoryItem * oldInventoryParent = itemMap.value(newInventoryParent->getPath()); + if (oldInventoryParent) + { + foreach (ModelItem * item, oldInventoryParent->getChildren()) + { + InventoryItem * invitem = qobject_cast(item); + if (!invitem) continue; - QString path = invitem->getPath(); - if (itemMap.contains(path)) - { - InventoryItem * oldItem = itemMap.value(path); - ModelItem * oldParent = oldItem->parent(); - int row = oldItem->row(); - removeRowsRecursive(oldParent, row, row); + QString path = invitem->getPath(); + if (itemMap.contains(path)) + { + InventoryItem * oldItem = itemMap.value(path); + ModelItem * oldParent = oldItem->parent(); + int row = oldItem->row(); + removeRowsRecursive(oldParent, row, row); + } + } } } @@ -359,7 +367,7 @@ void Inventory::insertRowsRecursive(Mode foreach (ModelItem * item, children) { - InventoryItem * invitem = dynamic_cast(item); + InventoryItem * invitem = qobject_cast(item); if (invitem) { QString path = invitem->getPath();