Skip to content

Commit f85389e

Browse files
committed
Resolve race condition when removing/add attachments inside of a LLWearableHoldingPattern (see PR for details)
1 parent 48bae10 commit f85389e

File tree

1 file changed

+50
-53
lines changed

1 file changed

+50
-53
lines changed

indra/newview/llappearancemgr.cpp

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ class LLWearableHoldingPattern
713713
found_list_t& getFoundList();
714714
void eraseTypeToLink(LLWearableType::EType type);
715715
void eraseTypeToRecover(LLWearableType::EType type);
716-
void setObjItems(const LLInventoryModel::item_array_t& items);
717716
void setGestItems(const LLInventoryModel::item_array_t& items);
718717
bool isMostRecent();
719718
void handleLateArrivals();
@@ -723,7 +722,6 @@ class LLWearableHoldingPattern
723722

724723
private:
725724
found_list_t mFoundList;
726-
LLInventoryModel::item_array_t mObjItems;
727725
LLInventoryModel::item_array_t mGestItems;
728726
typedef std::set<S32> type_set_t;
729727
type_set_t mTypesToRecover;
@@ -800,11 +798,6 @@ void LLWearableHoldingPattern::eraseTypeToRecover(LLWearableType::EType type)
800798
mTypesToRecover.erase(type);
801799
}
802800

803-
void LLWearableHoldingPattern::setObjItems(const LLInventoryModel::item_array_t& items)
804-
{
805-
mObjItems = items;
806-
}
807-
808801
void LLWearableHoldingPattern::setGestItems(const LLInventoryModel::item_array_t& items)
809802
{
810803
mGestItems = items;
@@ -910,55 +903,10 @@ void LLWearableHoldingPattern::onAllComplete()
910903

911904
if (isAgentAvatarValid())
912905
{
913-
LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.size() << " attachments" << LL_ENDL;
914-
LLAgentWearables::llvo_vec_t objects_to_remove;
915-
LLAgentWearables::llvo_vec_t objects_to_retain;
916-
LLInventoryModel::item_array_t items_to_add;
917-
918-
LLAgentWearables::findAttachmentsAddRemoveInfo(mObjItems,
919-
objects_to_remove,
920-
objects_to_retain,
921-
items_to_add);
922-
923-
LL_DEBUGS("Avatar") << self_av_string() << "Removing " << objects_to_remove.size()
924-
<< " attachments" << LL_ENDL;
925-
926-
// Here we remove the attachment pos overrides for *all*
927-
// attachments, even those that are not being removed. This is
928-
// needed to get joint positions all slammed down to their
929-
// pre-attachment states.
930-
gAgentAvatarp->clearAttachmentOverrides();
931-
932-
if (objects_to_remove.size() || items_to_add.size())
933-
{
934-
LL_DEBUGS("Avatar") << "ATT will remove " << objects_to_remove.size()
935-
<< " and add " << items_to_add.size() << " items" << LL_ENDL;
936-
}
937-
938-
// Take off the attachments that will no longer be in the outfit.
939-
LLAgentWearables::userRemoveMultipleAttachments(objects_to_remove);
940-
941906
// Update wearables.
942907
LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " updating agent wearables with "
943908
<< mResolved << " wearable items " << LL_ENDL;
944909
LLAppearanceMgr::instance().updateAgentWearables(this);
945-
946-
// Restore attachment pos overrides for the attachments that
947-
// are remaining in the outfit.
948-
for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_retain.begin();
949-
it != objects_to_retain.end();
950-
++it)
951-
{
952-
LLViewerObject *objectp = *it;
953-
if (!objectp->isAnimatedObject())
954-
{
955-
gAgentAvatarp->addAttachmentOverridesForObject(objectp);
956-
}
957-
}
958-
959-
// Add new attachments to match those requested.
960-
LL_DEBUGS("Avatar") << self_av_string() << "Adding " << items_to_add.size() << " attachments" << LL_ENDL;
961-
LLAgentWearables::userAttachMultipleAttachments(items_to_add);
962910
}
963911

964912
if (isFetchCompleted() && isMissingCompleted())
@@ -2589,6 +2537,56 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool enforce_item_restrictions,
25892537
<< " descendent_count " << cof->getDescendentCount()
25902538
<< " viewer desc count " << cof->getViewerDescendentCount() << LL_ENDL;
25912539
}
2540+
2541+
// Update attachments to match those requested.
2542+
if (isAgentAvatarValid())
2543+
{
2544+
LL_DEBUGS("Avatar") << self_av_string() << "Updating " << obj_items.size() << " attachments" << LL_ENDL;
2545+
LLAgentWearables::llvo_vec_t objects_to_remove;
2546+
LLAgentWearables::llvo_vec_t objects_to_retain;
2547+
LLInventoryModel::item_array_t items_to_add;
2548+
2549+
LLAgentWearables::findAttachmentsAddRemoveInfo(obj_items,
2550+
objects_to_remove,
2551+
objects_to_retain,
2552+
items_to_add);
2553+
2554+
LL_DEBUGS("Avatar") << self_av_string() << "Removing " << objects_to_remove.size()
2555+
<< " attachments" << LL_ENDL;
2556+
2557+
// Here we remove the attachment pos overrides for *all*
2558+
// attachments, even those that are not being removed. This is
2559+
// needed to get joint positions all slammed down to their
2560+
// pre-attachment states.
2561+
gAgentAvatarp->clearAttachmentOverrides();
2562+
2563+
if (objects_to_remove.size() || items_to_add.size())
2564+
{
2565+
LL_DEBUGS("Avatar") << "ATT will remove " << objects_to_remove.size()
2566+
<< " and add " << items_to_add.size() << " items" << LL_ENDL;
2567+
}
2568+
2569+
// Take off the attachments that will no longer be in the outfit.
2570+
LLAgentWearables::userRemoveMultipleAttachments(objects_to_remove);
2571+
2572+
// Restore attachment pos overrides for the attachments that
2573+
// are remaining in the outfit.
2574+
for (LLAgentWearables::llvo_vec_t::iterator it = objects_to_retain.begin();
2575+
it != objects_to_retain.end();
2576+
++it)
2577+
{
2578+
LLViewerObject *objectp = *it;
2579+
if (!objectp->isAnimatedObject())
2580+
{
2581+
gAgentAvatarp->addAttachmentOverridesForObject(objectp);
2582+
}
2583+
}
2584+
2585+
// Add new attachments to match those requested.
2586+
LL_DEBUGS("Avatar") << self_av_string() << "Adding " << items_to_add.size() << " attachments" << LL_ENDL;
2587+
LLAgentWearables::userAttachMultipleAttachments(items_to_add);
2588+
}
2589+
25922590
if(!wear_items.size())
25932591
{
25942592
LLNotificationsUtil::add("CouldNotPutOnOutfit");
@@ -2603,7 +2601,6 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool enforce_item_restrictions,
26032601
LLTimer hp_block_timer;
26042602
LLWearableHoldingPattern* holder = new LLWearableHoldingPattern;
26052603

2606-
holder->setObjItems(obj_items);
26072604
holder->setGestItems(gest_items);
26082605

26092606
// Note: can't do normal iteration, because if all the

0 commit comments

Comments
 (0)