From cb754c60a9431b1118ebac9a0946010ddbed8239 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 3 Apr 2018 22:37:54 +0000 Subject: MAINT-8465 Fixed Detaching then rezzing then wearing an attachment puts it in an invalid folder. --- indra/newview/llinventorymodel.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'indra/newview/llinventorymodel.cpp') diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 556af93963..60fe152876 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -925,7 +925,17 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) new_item = old_item; LLUUID old_parent_id = old_item->getParentUUID(); LLUUID new_parent_id = item->getParentUUID(); - + bool update_parent_on_server = false; + + if (new_parent_id.isNull()) + { + // item with null parent will end in random location and then in Lost&Found, + // either move to default folder as if it is new item or don't move at all + LL_DEBUGS(LOG_INV) << "Update attempts to reparent item to null folder. Resorting!" << LL_ENDL; + new_parent_id = findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(new_item->getType())); + update_parent_on_server = true; + } + if(old_parent_id != new_parent_id) { // need to update the parent-child tree @@ -947,6 +957,14 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) mask |= LLInventoryObserver::LABEL; } old_item->copyViewerItem(item); + if (update_parent_on_server) + { + LLInventoryModel::LLCategoryUpdate update(new_parent_id, 1); + gInventory.accountForUpdate(update); + // Update on server or item will end up in Lost&Found + old_item->setParent(new_parent_id); + new_item->updateParentOnServer(FALSE); + } mask |= LLInventoryObserver::INTERNAL; } else @@ -2820,7 +2838,6 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, U32 item_array_t items; update_map_t update; S32 count = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); - LLUUID folder_id; // Does this loop ever execute more than once? for(S32 i = 0; i < count; ++i) { @@ -2847,10 +2864,6 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, U32 { ++update[titem->getParentUUID()]; } - if (folder_id.isNull()) - { - folder_id = titem->getParentUUID(); - } } if(account) { -- cgit v1.2.3 From bf60675ee5bca3e6e388a6dd62debdf3e7eca8ec Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 5 Apr 2018 17:01:19 +0300 Subject: MAINT-8465 Item should be moved to lost and found folder --- indra/newview/llinventorymodel.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'indra/newview/llinventorymodel.cpp') diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 60fe152876..76bf87cfe5 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -931,8 +931,11 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) { // item with null parent will end in random location and then in Lost&Found, // either move to default folder as if it is new item or don't move at all - LL_DEBUGS(LOG_INV) << "Update attempts to reparent item to null folder. Resorting!" << LL_ENDL; - new_parent_id = findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(new_item->getType())); + LL_WARNS(LOG_INV) << "Update attempts to reparent item " << item->getUUID() + << " to null folder. Moving to Lost&Found. Old item name: " << old_item->getName() + << ". New name: " << item->getName() + << "." << LL_ENDL; + new_parent_id = findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); update_parent_on_server = true; } @@ -948,6 +951,11 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) item_array = get_ptr_in_map(mParentChildItemTree, new_parent_id); if(item_array) { + if (update_parent_on_server) + { + LLInventoryModel::LLCategoryUpdate update(new_parent_id, 1); + gInventory.accountForUpdate(update); + } item_array->push_back(old_item); } mask |= LLInventoryObserver::STRUCTURE; @@ -959,9 +967,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) old_item->copyViewerItem(item); if (update_parent_on_server) { - LLInventoryModel::LLCategoryUpdate update(new_parent_id, 1); - gInventory.accountForUpdate(update); - // Update on server or item will end up in Lost&Found + // Parent id at server is null, so update server even if item already is in the same folder old_item->setParent(new_parent_id); new_item->updateParentOnServer(FALSE); } -- cgit v1.2.3