diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-05-15 12:51:21 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-05-15 12:51:21 +0300 |
commit | d9153532b8637cbfe992200effb1d24c597a732f (patch) | |
tree | 123a168e400480ce9a8de780e068c232172c85cc /indra/newview/llviewermenu.cpp | |
parent | b06a99f7c76950484972e25d9dbbee8660a6a6c3 (diff) | |
parent | bb3c36f5cbc0c3b542045fd27255eee24e03da22 (diff) |
Merge branch 'main' into marchcat/x-mf-merge
# Conflicts:
# doc/contributions.txt
# indra/newview/llfloaterimagepreview.cpp
Diffstat (limited to 'indra/newview/llviewermenu.cpp')
-rw-r--r-- | indra/newview/llviewermenu.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 8da467021d..4dcfb18b30 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7379,37 +7379,70 @@ class LLAttachmentDetach : public view_listener_t { // Called when the user clicked on an object attached to them // and selected "Detach". - LLViewerObject *object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + LLViewerObject *object = selection->getPrimaryObject(); if (!object) { LL_WARNS() << "handle_detach() - no object to detach" << LL_ENDL; return true; } - LLViewerObject *parent = (LLViewerObject*)object->getParent(); - while (parent) + struct f: public LLSelectedObjectFunctor { - if(parent->isAvatar()) + f() : mAvatarsInSelection(false) {} + virtual bool apply(LLViewerObject* objectp) { - break; + if (!objectp) + { + return false; + } + + if (objectp->isAvatar()) + { + mAvatarsInSelection = true; + return false; + } + + LLViewerObject* parent = (LLViewerObject*)objectp->getParent(); + while (parent) + { + if (parent->isAvatar()) + { + break; + } + objectp = parent; + parent = (LLViewerObject*)parent->getParent(); + } + + // std::set to avoid dupplicate 'roots' from linksets + mRemoveSet.insert(objectp->getAttachmentItemID()); + + return true; } - object = parent; - parent = (LLViewerObject*)parent->getParent(); - } + bool mAvatarsInSelection; + uuid_set_t mRemoveSet; + } func; + // Probbly can run applyToRootObjects instead, + // but previous version of this code worked for any selected object + selection->applyToObjects(&func); - if (!object) + if (func.mAvatarsInSelection) { - LL_WARNS() << "handle_detach() - no object to detach" << LL_ENDL; + // Not possible under normal circumstances + // Either avatar selection is ON or has to do with animeshes + // Better stop this than mess something + LL_WARNS() << "Trying to detach avatar from avatar." << LL_ENDL; return true; } - if (object->isAvatar()) + if (func.mRemoveSet.empty()) { - LL_WARNS() << "Trying to detach avatar from avatar." << LL_ENDL; + LL_WARNS() << "handle_detach() - no valid attachments in selection to detach" << LL_ENDL; return true; } - LLAppearanceMgr::instance().removeItemFromAvatar(object->getAttachmentItemID()); + uuid_vec_t detach_list(func.mRemoveSet.begin(), func.mRemoveSet.end()); + LLAppearanceMgr::instance().removeItemsFromAvatar(detach_list); return true; } |