From 975630a2fb78edc83e8e8cf04a956d50e9e72030 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 8 Dec 2017 10:11:13 +0100 Subject: [PATCH] Fix avatar names often not showing on first open of properties floater --- indra/newview/llfloaterproperties.cpp | 124 ++++++++++++++++++-------- indra/newview/llfloaterproperties.h | 14 +++ 2 files changed, 102 insertions(+), 36 deletions(-) diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp index 7deb450137..5a33ea2d38 100644 --- a/indra/newview/llfloaterproperties.cpp +++ b/indra/newview/llfloaterproperties.cpp @@ -114,6 +114,11 @@ void LLPropertiesObserver::changed(U32 mask) LLFloaterProperties::LLFloaterProperties(const LLSD& key) : LLFloater(key), mDirty(TRUE) + // Avatar names often not showing on first open + ,mCreatorNameCbConnection(), + mOwnerNameCbConnection(), + mGroupOwnerNameCbConnection() + // { if (key.has("item_id")) { @@ -129,6 +134,21 @@ LLFloaterProperties::~LLFloaterProperties() { delete mPropertiesObserver; mPropertiesObserver = NULL; + + // Avatar names often not showing on first open + if (mCreatorNameCbConnection.connected()) + { + mCreatorNameCbConnection.disconnect(); + } + if (mOwnerNameCbConnection.connected()) + { + mOwnerNameCbConnection.disconnect(); + } + if (mGroupOwnerNameCbConnection.connected()) + { + mGroupOwnerNameCbConnection.disconnect(); + } + // } // virtual @@ -303,23 +323,19 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) if (item->getCreatorUUID().notNull()) { - LLAvatarName av_name; - LLAvatarNameCache::get(item->getCreatorUUID(), &av_name); - getChildView("BtnCreator")->setEnabled(TRUE); + // Avatar names often not showing on first open + //LLAvatarName av_name; + //LLAvatarNameCache::get(item->getCreatorUUID(), &av_name); + //getChildView("BtnCreator")->setEnabled(TRUE); + // getChildView("LabelCreatorTitle")->setEnabled(TRUE); getChildView("LabelCreatorName")->setEnabled(TRUE); -// [RLVa:KB] - Checked: RLVa-2.0.1 - std::string name = av_name.getUserName(); - // If the object creator matches the object owner we need to anonymize the creator field as well - if ( (!RlvActions::canShowName(RlvActions::SNC_DEFAULT, item->getCreatorUUID())) && - ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) ) || (RlvUtil::isNearbyAgent(item->getCreatorUUID())) ) ) - { - childSetEnabled("BtnCreator", FALSE); - name = RlvStrings::getAnonym(av_name); - } - getChild("LabelCreatorName")->setValue(name); -// [/RLVa:KB] -// getChild("LabelCreatorName")->setValue(av_name.getUserName()); + // Avatar names often not showing on first open + //getChild("LabelCreatorName")->setValue(av_name.getUserName()); + getChildView("BtnCreator")->setEnabled(FALSE); + getChild("LabelCreatorName")->setValue(LLTrans::getString("AvatarNameWaiting")); + mCreatorNameCbConnection = LLAvatarNameCache::get(item->getCreatorUUID(), boost::bind(&LLFloaterProperties::onCreatorNameCallback, this, _1, _2, perm)); + // } else { @@ -334,35 +350,31 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) //////////////// if(perm.isOwned()) { -// [RLVa:KB] - Checked: RVLa-2.0.1 - bool fRlvCanShowOwner = true; -// [/RLVa:KB] - std::string name; + // Avatar names often not showing on first open + //std::string name; + getChildView("BtnOwner")->setEnabled(FALSE); + getChild("LabelOwnerName")->setValue(LLTrans::getString("AvatarNameWaiting")); + // if (perm.isGroupOwned()) { - gCacheName->getGroupName(perm.getGroup(), name); + // Avatar names often not showing on first open + //gCacheName->getGroupName(perm.getGroup(), name); + mGroupOwnerNameCbConnection = gCacheName->getGroup(perm.getGroup(), boost::bind(&LLFloaterProperties::onGroupOwnerNameCallback, this, _2)); + // } else { - LLAvatarName av_name; - LLAvatarNameCache::get(perm.getOwner(), &av_name); - name = av_name.getUserName(); -// [RLVa:KB] - Checked: RLVa-2.0.1 - if (RlvActions::isRlvEnabled()) - { - fRlvCanShowOwner = RlvActions::canShowName(RlvActions::SNC_DEFAULT, perm.getOwner()); - if (!fRlvCanShowOwner) - name = RlvStrings::getAnonym(av_name); - } -// [/RLVa:KB] + // Avatar names often not showing on first open + //LLAvatarName av_name; + //LLAvatarNameCache::get(perm.getOwner(), &av_name); + //name = av_name.getUserName(); + mOwnerNameCbConnection = LLAvatarNameCache::get(perm.getOwner(), boost::bind(&LLFloaterProperties::onOwnerNameCallback, this, _1, _2)); + // } -// getChildView("BtnOwner")->setEnabled(TRUE); -// [RLVa:KB] - Checked: RLVa-2.0.1 - getChildView("BtnOwner")->setEnabled(fRlvCanShowOwner); -// [/RLVa:KB] + //getChildView("BtnOwner")->setEnabled(TRUE); // Avatar names often not showing on first open getChildView("LabelOwnerTitle")->setEnabled(TRUE); getChildView("LabelOwnerName")->setEnabled(TRUE); - getChild("LabelOwnerName")->setValue(name); + //getChild("LabelOwnerName")->setValue(name); // Avatar names often not showing on first open } else { @@ -979,6 +991,46 @@ void LLFloaterProperties::dirtyAll() } } +// Avatar names often not showing on first open +void LLFloaterProperties::onCreatorNameCallback(const LLUUID& av_id, const LLAvatarName& av_name, const LLPermissions& perm) +{ + bool enabled = true; + std::string name = av_name.getUserName(); + // If the object creator matches the object owner we need to anonymize the creator field as well + if ( (!RlvActions::canShowName(RlvActions::SNC_DEFAULT, av_id)) && + ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == av_id) ) || (RlvUtil::isNearbyAgent(av_id)) ) ) + { + enabled = false; + name = RlvStrings::getAnonym(av_name); + } + getChild("LabelCreatorName")->setValue(name); + childSetEnabled("BtnCreator", enabled); +} + +void LLFloaterProperties::onOwnerNameCallback(const LLUUID& av_id, const LLAvatarName& av_name) +{ + bool fRlvCanShowOwner = true; + std::string name = av_name.getUserName(); + if (RlvActions::isRlvEnabled()) + { + fRlvCanShowOwner = RlvActions::canShowName(RlvActions::SNC_DEFAULT, av_id); + if (!fRlvCanShowOwner) + { + name = RlvStrings::getAnonym(av_name); + } + } + + getChild("LabelOwnerName")->setValue(name); + getChildView("BtnOwner")->setEnabled(fRlvCanShowOwner); +} + +void LLFloaterProperties::onGroupOwnerNameCallback(const std::string& name) +{ + getChild("LabelOwnerName")->setValue(name); + getChildView("BtnOwner")->setEnabled(TRUE); +} +// + ///---------------------------------------------------------------------------- /// LLMultiProperties ///---------------------------------------------------------------------------- diff --git a/indra/newview/llfloaterproperties.h b/indra/newview/llfloaterproperties.h index 3612887a47..b8099b6525 100644 --- a/indra/newview/llfloaterproperties.h +++ b/indra/newview/llfloaterproperties.h @@ -44,6 +44,11 @@ class LLTextBox; class LLPropertiesObserver; +// Avatar names often not showing on first open +class LLAvatarName; +class LLPermissions; +// + class LLFloaterProperties : public LLFloater { public: @@ -90,6 +95,15 @@ protected: BOOL mDirty; LLPropertiesObserver* mPropertiesObserver; + + // Avatar names often not showing on first open + boost::signals2::connection mCreatorNameCbConnection; + boost::signals2::connection mOwnerNameCbConnection; + boost::signals2::connection mGroupOwnerNameCbConnection; + void onCreatorNameCallback(const LLUUID& av_id, const LLAvatarName& av_name, const LLPermissions& perm); + void onOwnerNameCallback(const LLUUID& av_id, const LLAvatarName& av_name); + void onGroupOwnerNameCallback(const std::string& name); + // }; class LLMultiProperties : public LLMultiFloater