diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 74a8d8fe1583c452ff44165f1c29f4f62684c15e..dfed1cb57a99f663e2d3d6f33380d2720aab739d 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -863,14 +863,37 @@ void LLAppearanceManager::wearOutfitByName(const std::string& name) /* static */ void LLAppearanceManager::wearItem( LLInventoryItem* item, bool do_update ) { - // BAP add check for already in COF. - LLPointer<LLInventoryCallback> cb = do_update ? new ModifiedCOFCallback : 0; - link_inventory_item( gAgent.getID(), - item->getLinkedUUID(), - getCOF(), - item->getName(), - LLAssetType::AT_LINK, - cb); + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceManager::getCOF(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + bool linked_already = false; + for (S32 i=0; i<item_array.count(); i++) + { + const LLInventoryItem* inv_item = item_array.get(i).get(); + if (inv_item->getLinkedUUID() == item->getLinkedUUID()) + { + linked_already = true; + break; + } + } + if (linked_already) + { + if (do_update) + LLAppearanceManager::updateAppearanceFromCOF(); + } + else + { + LLPointer<LLInventoryCallback> cb = do_update ? new ModifiedCOFCallback : 0; + link_inventory_item( gAgent.getID(), + item->getLinkedUUID(), + getCOF(), + item->getName(), + LLAssetType::AT_LINK, + cb); + } } /* static */