From ffc33a1cc5b96d9ae6de7f447c09de3ae8174fbc Mon Sep 17 00:00:00 2001 From: Kelly Washington Date: Mon, 15 Oct 2012 16:46:42 -0700 Subject: MAINT-1598 Edit Linked Parts isn't returning creator/owner * Show creator, owner and group information when only selecting a single prim in a linkset. reviewed with Simon --- indra/newview/llpanelpermissions.cpp | 2 +- indra/newview/llselectmgr.cpp | 301 +++++++++++++++++------------------ indra/newview/llselectmgr.h | 6 + 3 files changed, 156 insertions(+), 153 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index 51ab7649a4..e641370d2e 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -425,7 +425,7 @@ void LLPanelPermissions::refresh() } } - getChildView("button set group")->setEnabled(owners_identical && (mOwnerID == gAgent.getID()) && is_nonpermanent_enforced); + getChildView("button set group")->setEnabled(root_selected && owners_identical && (mOwnerID == gAgent.getID()) && is_nonpermanent_enforced); getChildView("Name:")->setEnabled(TRUE); LLLineEditor* LineEditorObjectName = getChild("Object Name"); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 13845c3b38..9c4c594280 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2941,116 +2941,148 @@ BOOL LLSelectMgr::selectGetRootsCopy() return TRUE; } -//----------------------------------------------------------------------------- -// selectGetCreator() -// Creator information only applies to root objects. -//----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetCreator(LLUUID& result_id, std::string& name) +struct LLSelectGetFirstTest { - BOOL identical = TRUE; - BOOL first = TRUE; - LLUUID first_id; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) + LLSelectGetFirstTest() : mIdentical(true), mFirst(true) { } + virtual ~LLSelectGetFirstTest() { } + + // returns false to break out of the iteration. + bool checkMatchingNode(LLSelectNode* node) { - LLSelectNode* node = *iter; - if (!node->mValid) + if (!node || !node->mValid) { - return FALSE; + return false; } - if (first) + if (mFirst) { - first_id = node->mPermissions->getCreator(); - first = FALSE; + mFirstValue = getValueFromNode(node); + mFirst = false; } else { - if ( !(first_id == node->mPermissions->getCreator() ) ) + if ( mFirstValue != getValueFromNode(node) ) + { + mIdentical = false; + // stop testing once we know not all selected are identical. + return false; + } + } + // continue testing. + return true; + } + + bool mIdentical; + LLUUID mFirstValue; + +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) = 0; + +private: + bool mFirst; +}; + +void LLSelectMgr::getFirst(LLSelectGetFirstTest* test) +{ + if (gSavedSettings.getBOOL("EditLinkedParts")) + { + for (LLObjectSelection::valid_iterator iter = getSelection()->valid_begin(); + iter != getSelection()->valid_end(); ++iter ) + { + if (!test->checkMatchingNode(*iter)) { - identical = FALSE; break; } } } - if (first_id.isNull()) + else + { + for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); + iter != getSelection()->root_object_end(); ++iter ) + { + if (!test->checkMatchingNode(*iter)) + { + break; + } + } + } +} + +//----------------------------------------------------------------------------- +// selectGetCreator() +// Creator information only applies to roots unless editing linked parts. +//----------------------------------------------------------------------------- +struct LLSelectGetFirstCreator : public LLSelectGetFirstTest +{ +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) + { + return node->mPermissions->getCreator(); + } +}; + +BOOL LLSelectMgr::selectGetCreator(LLUUID& result_id, std::string& name) +{ + LLSelectGetFirstCreator test; + getFirst(&test); + + if (test.mFirstValue.isNull()) { name = LLTrans::getString("AvatarNameNobody"); return FALSE; } - result_id = first_id; + result_id = test.mFirstValue; - if (identical) + if (test.mIdentical) { - name = LLSLURL("agent", first_id, "inspect").getSLURLString(); + name = LLSLURL("agent", test.mFirstValue, "inspect").getSLURLString(); } else { name = LLTrans::getString("AvatarNameMultiple"); } - return identical; + return test.mIdentical; } - //----------------------------------------------------------------------------- // selectGetOwner() -// Owner information only applies to roots. +// Owner information only applies to roots unless editing linked parts. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetOwner(LLUUID& result_id, std::string& name) +struct LLSelectGetFirstOwner : public LLSelectGetFirstTest { - BOOL identical = TRUE; - BOOL first = TRUE; - BOOL first_group_owned = FALSE; - LLUUID first_id; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) { - LLSelectNode* node = *iter; - if (!node->mValid) - { - return FALSE; - } - - if (first) - { - node->mPermissions->getOwnership(first_id, first_group_owned); - first = FALSE; - } - else - { - LLUUID owner_id; - BOOL is_group_owned = FALSE; - if (!(node->mPermissions->getOwnership(owner_id, is_group_owned)) - || owner_id != first_id || is_group_owned != first_group_owned) - { - identical = FALSE; - break; - } - } + // Don't use 'getOwnership' since we return a reference, not a copy. + // Will return LLUUID::null if unowned (which is not allowed and should never happen.) + return node->mPermissions->isGroupOwned() ? node->mPermissions->getGroup() : node->mPermissions->getOwner(); } - if (first_id.isNull()) +}; + +BOOL LLSelectMgr::selectGetOwner(LLUUID& result_id, std::string& name) +{ + LLSelectGetFirstOwner test; + getFirst(&test); + + if (test.mFirstValue.isNull()) { return FALSE; } - result_id = first_id; + result_id = test.mFirstValue; - if (identical) + if (test.mIdentical) { - BOOL public_owner = (first_id.isNull() && !first_group_owned); - if (first_group_owned) + bool group_owned = selectIsGroupOwned(); + if (group_owned) { - name = LLSLURL("group", first_id, "inspect").getSLURLString(); - } - else if(!public_owner) - { - name = LLSLURL("agent", first_id, "inspect").getSLURLString(); + name = LLSLURL("group", test.mFirstValue, "inspect").getSLURLString(); } else { - name = LLTrans::getString("AvatarNameNobody"); + name = LLSLURL("agent", test.mFirstValue, "inspect").getSLURLString(); } } else @@ -3058,131 +3090,92 @@ BOOL LLSelectMgr::selectGetOwner(LLUUID& result_id, std::string& name) name = LLTrans::getString("AvatarNameMultiple"); } - return identical; + return test.mIdentical; } - //----------------------------------------------------------------------------- // selectGetLastOwner() -// Owner information only applies to roots. +// Owner information only applies to roots unless editing linked parts. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetLastOwner(LLUUID& result_id, std::string& name) +struct LLSelectGetFirstLastOwner : public LLSelectGetFirstTest { - BOOL identical = TRUE; - BOOL first = TRUE; - LLUUID first_id; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) { - LLSelectNode* node = *iter; - if (!node->mValid) - { - return FALSE; - } - - if (first) - { - first_id = node->mPermissions->getLastOwner(); - first = FALSE; - } - else - { - if ( !(first_id == node->mPermissions->getLastOwner() ) ) - { - identical = FALSE; - break; - } - } + return node->mPermissions->getLastOwner(); } - if (first_id.isNull()) +}; + +BOOL LLSelectMgr::selectGetLastOwner(LLUUID& result_id, std::string& name) +{ + LLSelectGetFirstLastOwner test; + getFirst(&test); + + if (test.mFirstValue.isNull()) { return FALSE; } - result_id = first_id; + result_id = test.mFirstValue; - if (identical) + if (test.mIdentical) { - BOOL public_owner = (first_id.isNull()); - if(!public_owner) - { - name = LLSLURL("agent", first_id, "inspect").getSLURLString(); - } - else - { - name.assign("Public or Group"); - } + name = LLSLURL("agent", test.mFirstValue, "inspect").getSLURLString(); } else { name.assign( "" ); } - return identical; + return test.mIdentical; } - //----------------------------------------------------------------------------- // selectGetGroup() -// Group information only applies to roots. +// Group information only applies to roots unless editing linked parts. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetGroup(LLUUID& result_id) +struct LLSelectGetFirstGroup : public LLSelectGetFirstTest { - BOOL identical = TRUE; - BOOL first = TRUE; - LLUUID first_id; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) { - LLSelectNode* node = *iter; - if (!node->mValid) - { - return FALSE; - } - - if (first) - { - first_id = node->mPermissions->getGroup(); - first = FALSE; - } - else - { - if ( !(first_id == node->mPermissions->getGroup() ) ) - { - identical = FALSE; - break; - } - } + return node->mPermissions->getGroup(); } +}; - result_id = first_id; +BOOL LLSelectMgr::selectGetGroup(LLUUID& result_id) +{ + LLSelectGetFirstGroup test; + getFirst(&test); - return identical; + result_id = test.mFirstValue; + return test.mIdentical; } //----------------------------------------------------------------------------- // selectIsGroupOwned() -// Only operates on root nodes. -// Returns TRUE if all have valid data and they are all group owned. +// Only operates on root nodes unless editing linked parts. +// Returns TRUE if the first selected is group owned. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectIsGroupOwned() +struct LLSelectGetFirstGroupOwner : public LLSelectGetFirstTest { - BOOL found_one = FALSE; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) { - LLSelectNode* node = *iter; - if (!node->mValid) + if (node->mPermissions->isGroupOwned()) { - return FALSE; - } - found_one = TRUE; - if (!node->mPermissions->isGroupOwned()) - { - return FALSE; + return node->mPermissions->getGroup(); } - } - return found_one ? TRUE : FALSE; + return LLUUID::null; + } +}; + +BOOL LLSelectMgr::selectIsGroupOwned() +{ + LLSelectGetFirstGroupOwner test; + getFirst(&test); + + return test.mFirstValue.notNull() ? TRUE : FALSE; } //----------------------------------------------------------------------------- @@ -4987,7 +4980,11 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data } func(id); LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func); - if (node) + if (!node) + { + llwarns << "Couldn't find object " << id << " selected." << llendl; + } + else { if (node->mInventorySerial != inv_serial) { diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index ecbb20df1b..9257ee9eeb 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -343,6 +343,9 @@ typedef LLSafeHandle LLObjectSelectionHandle; extern template class LLSelectMgr* LLSingleton::getInstance(); #endif +// For use with getFirstTest() +struct LLSelectGetFirstTest; + class LLSelectMgr : public LLEditMenuHandler, public LLSingleton { public: @@ -745,6 +748,9 @@ private: static void packGodlikeHead(void* user_data); static bool confirmDelete(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle handle); + // Get the first ID that matches test and whether or not all ids are identical in selected objects. + void getFirst(LLSelectGetFirstTest* test); + public: // Observer/callback support for when object selection changes or // properties are received/updated -- cgit v1.2.3