Skip to content

Commit 4c8f846

Browse files
#1664 retain clothing order when Replacing Link with the same wearable type
1 parent 47aa16e commit 4c8f846

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

indra/newview/llfloaterlinkreplace.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,21 @@ void LLFloaterLinkReplace::linkCreatedCallback(LLHandle<LLFloaterLinkReplace> fl
225225
<< " - description update = " << (needs_description_update ? "true" : "false") << LL_NEWLINE
226226
<< " - outfit_folder_id = " << outfit_folder_id.asString() << LL_ENDL;
227227

228+
std::string old_description;
229+
if (needs_wearable_ordering_update)
230+
{
231+
LLViewerInventoryItem* old_item = gInventory.getItem(old_item_id);
232+
LLViewerInventoryItem* target_item = gInventory.getItem(target_item_id);
233+
if (old_item && target_item &&
234+
old_item->getType() == LLAssetType::AT_CLOTHING &&
235+
target_item->getType() == LLAssetType::AT_CLOTHING &&
236+
old_item->getWearableType() == target_item->getWearableType())
237+
{
238+
// Preserve the original description, which contains ordering info
239+
old_description = old_item->getActualDescription();
240+
}
241+
}
242+
228243
// If we are replacing an object, bodypart or gesture link within an outfit folder,
229244
// we need to change the actual description of the link itself. LLAppearanceMgr *should*
230245
// have created COF links that will be used to save the outfit with an empty description.
@@ -246,7 +261,14 @@ void LLFloaterLinkReplace::linkCreatedCallback(LLHandle<LLFloaterLinkReplace> fl
246261
{
247262
LLPointer<LLViewerInventoryItem> item = *it;
248263

249-
if ((item->getType() == LLAssetType::AT_BODYPART ||
264+
if (item->getType() == LLAssetType::AT_CLOTHING && !old_description.empty())
265+
{
266+
// Use the old description to set ordering info
267+
LLSD updates;
268+
updates["desc"] = old_description;
269+
update_inventory_item(item->getUUID(), updates, LLPointer<LLInventoryCallback>(NULL));
270+
}
271+
else if ((item->getType() == LLAssetType::AT_BODYPART ||
250272
item->getType() == LLAssetType::AT_OBJECT ||
251273
item->getType() == LLAssetType::AT_GESTURE)
252274
&& !item->getActualDescription().empty())
@@ -347,12 +369,9 @@ void LLFloaterLinkReplace::processBatch(LLInventoryModel::item_array_t items)
347369
bool is_outfit_folder = gInventory.isObjectDescendentOf(source_item->getParentUUID(), outfit_folder_id);
348370
// If either the new or old item in the COF is a wearable, we need to update wearable ordering after the link has been replaced
349371
bool needs_wearable_ordering_update = (is_outfit_folder && source_item->getType() == LLAssetType::AT_CLOTHING) || target_item->getType() == LLAssetType::AT_CLOTHING;
350-
// Other items in the COF need a description update (description of the actual link item must be empty)
351-
bool needs_description_update = is_outfit_folder && target_item->getType() != LLAssetType::AT_CLOTHING;
352372

353373
LL_DEBUGS() << "is_outfit_folder = " << (is_outfit_folder ? "true" : "false") << LL_NEWLINE
354-
<< "needs_wearable_ordering_update = " << (needs_wearable_ordering_update ? "true" : "false") << LL_NEWLINE
355-
<< "needs_description_update = " << (needs_description_update ? "true" : "false") << LL_ENDL;
374+
<< "needs_wearable_ordering_update = " << (needs_wearable_ordering_update ? "true" : "false") << LL_ENDL;
356375

357376
LLInventoryObject::const_object_list_t obj_array;
358377
obj_array.push_back(LLConstPointer<LLInventoryObject>(target_item));
@@ -361,7 +380,7 @@ void LLFloaterLinkReplace::processBatch(LLInventoryModel::item_array_t items)
361380
source_item->getUUID(),
362381
target_item->getUUID(),
363382
needs_wearable_ordering_update,
364-
needs_description_update,
383+
is_outfit_folder,
365384
(is_outfit_folder ? source_item->getParentUUID() : LLUUID::null) ));
366385
link_inventory_array(source_item->getParentUUID(), obj_array, cb);
367386
}

0 commit comments

Comments
 (0)