Fix avatar names often not showing on first open of properties floater

Fri, 08 Dec 2017 10:11:13 +0100

author
Ansariel
date
Fri, 08 Dec 2017 10:11:13 +0100
changeset 53557
2aa1306d361f
parent 53556
728a9c35d025
child 53558
c68dfe8d1359

Fix avatar names often not showing on first open of properties floater

indra/newview/llfloaterproperties.cpp file | annotate | diff | revisions
indra/newview/llfloaterproperties.h file | annotate | diff | revisions
     1.1 --- a/indra/newview/llfloaterproperties.cpp	Thu Dec 07 11:10:51 2017 +0200
     1.2 +++ b/indra/newview/llfloaterproperties.cpp	Fri Dec 08 10:11:13 2017 +0100
     1.3 @@ -114,6 +114,11 @@
     1.4  LLFloaterProperties::LLFloaterProperties(const LLSD& key)
     1.5    : LLFloater(key),
     1.6  	mDirty(TRUE)
     1.7 +	// <FS:Ansariel> Avatar names often not showing on first open
     1.8 +	,mCreatorNameCbConnection(),
     1.9 +	mOwnerNameCbConnection(),
    1.10 +	mGroupOwnerNameCbConnection()
    1.11 +	// </FS:Ansariel>
    1.12  {
    1.13  	if (key.has("item_id"))
    1.14  	{
    1.15 @@ -129,6 +134,21 @@
    1.16  {
    1.17  	delete mPropertiesObserver;
    1.18  	mPropertiesObserver = NULL;
    1.19 +
    1.20 +	// <FS:Ansariel> Avatar names often not showing on first open
    1.21 +	if (mCreatorNameCbConnection.connected())
    1.22 +	{
    1.23 +		mCreatorNameCbConnection.disconnect();
    1.24 +	}
    1.25 +	if (mOwnerNameCbConnection.connected())
    1.26 +	{
    1.27 +		mOwnerNameCbConnection.disconnect();
    1.28 +	}
    1.29 +	if (mGroupOwnerNameCbConnection.connected())
    1.30 +	{
    1.31 +		mGroupOwnerNameCbConnection.disconnect();
    1.32 +	}
    1.33 +	// </FS:Ansariel>
    1.34  }
    1.35  
    1.36  // virtual
    1.37 @@ -303,23 +323,19 @@
    1.38  
    1.39  	if (item->getCreatorUUID().notNull())
    1.40  	{
    1.41 -		LLAvatarName av_name;
    1.42 -		LLAvatarNameCache::get(item->getCreatorUUID(), &av_name);
    1.43 -		getChildView("BtnCreator")->setEnabled(TRUE);
    1.44 +		// <FS:Ansariel> Avatar names often not showing on first open
    1.45 +		//LLAvatarName av_name;
    1.46 +		//LLAvatarNameCache::get(item->getCreatorUUID(), &av_name);
    1.47 +		//getChildView("BtnCreator")->setEnabled(TRUE); 
    1.48 +		// </FS:Ansariel>
    1.49  		getChildView("LabelCreatorTitle")->setEnabled(TRUE);
    1.50  		getChildView("LabelCreatorName")->setEnabled(TRUE);
    1.51 -// [RLVa:KB] - Checked: RLVa-2.0.1
    1.52 -		std::string name = av_name.getUserName();
    1.53 -		// If the object creator matches the object owner we need to anonymize the creator field as well
    1.54 -		if ( (!RlvActions::canShowName(RlvActions::SNC_DEFAULT, item->getCreatorUUID())) &&
    1.55 -		     ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) ) || (RlvUtil::isNearbyAgent(item->getCreatorUUID())) ) )
    1.56 -		{
    1.57 -			childSetEnabled("BtnCreator", FALSE);
    1.58 -			name = RlvStrings::getAnonym(av_name);
    1.59 -		}
    1.60 -		getChild<LLUICtrl>("LabelCreatorName")->setValue(name);
    1.61 -// [/RLVa:KB]
    1.62 -//		getChild<LLUICtrl>("LabelCreatorName")->setValue(av_name.getUserName());
    1.63 +		// <FS:Ansariel> Avatar names often not showing on first open
    1.64 +		//getChild<LLUICtrl>("LabelCreatorName")->setValue(av_name.getUserName());
    1.65 +		getChildView("BtnCreator")->setEnabled(FALSE);
    1.66 +		getChild<LLUICtrl>("LabelCreatorName")->setValue(LLTrans::getString("AvatarNameWaiting"));
    1.67 +		mCreatorNameCbConnection = LLAvatarNameCache::get(item->getCreatorUUID(), boost::bind(&LLFloaterProperties::onCreatorNameCallback, this, _1, _2, perm));
    1.68 +		// </FS:Ansariel>
    1.69  	}
    1.70  	else
    1.71  	{
    1.72 @@ -334,35 +350,31 @@
    1.73  	////////////////
    1.74  	if(perm.isOwned())
    1.75  	{
    1.76 -// [RLVa:KB] - Checked: RVLa-2.0.1
    1.77 -		bool fRlvCanShowOwner = true;
    1.78 -// [/RLVa:KB]
    1.79 -		std::string name;
    1.80 +		// <FS:Ansariel> Avatar names often not showing on first open
    1.81 +		//std::string name;
    1.82 +		getChildView("BtnOwner")->setEnabled(FALSE);
    1.83 +		getChild<LLUICtrl>("LabelOwnerName")->setValue(LLTrans::getString("AvatarNameWaiting"));
    1.84 +		// </FS:Ansariel>
    1.85  		if (perm.isGroupOwned())
    1.86  		{
    1.87 -			gCacheName->getGroupName(perm.getGroup(), name);
    1.88 +			// <FS:Ansariel> Avatar names often not showing on first open
    1.89 +			//gCacheName->getGroupName(perm.getGroup(), name);
    1.90 +			mGroupOwnerNameCbConnection = gCacheName->getGroup(perm.getGroup(), boost::bind(&LLFloaterProperties::onGroupOwnerNameCallback, this, _2));
    1.91 +			// </FS:Ansariel>
    1.92  		}
    1.93  		else
    1.94  		{
    1.95 -			LLAvatarName av_name;
    1.96 -			LLAvatarNameCache::get(perm.getOwner(), &av_name);
    1.97 -			name = av_name.getUserName();
    1.98 -// [RLVa:KB] - Checked: RLVa-2.0.1
    1.99 -			if (RlvActions::isRlvEnabled())
   1.100 -			{
   1.101 -				fRlvCanShowOwner = RlvActions::canShowName(RlvActions::SNC_DEFAULT, perm.getOwner());
   1.102 -				if (!fRlvCanShowOwner)
   1.103 -					name = RlvStrings::getAnonym(av_name);
   1.104 -			}
   1.105 -// [/RLVa:KB]
   1.106 +			// <FS:Ansariel> Avatar names often not showing on first open
   1.107 +			//LLAvatarName av_name;
   1.108 +			//LLAvatarNameCache::get(perm.getOwner(), &av_name);
   1.109 +			//name = av_name.getUserName();
   1.110 +			mOwnerNameCbConnection = LLAvatarNameCache::get(perm.getOwner(), boost::bind(&LLFloaterProperties::onOwnerNameCallback, this, _1, _2));
   1.111 +			// </FS:Ansariel>
   1.112  		}
   1.113 -//		getChildView("BtnOwner")->setEnabled(TRUE);
   1.114 -// [RLVa:KB] - Checked: RLVa-2.0.1
   1.115 -		getChildView("BtnOwner")->setEnabled(fRlvCanShowOwner);
   1.116 -// [/RLVa:KB]
   1.117 +		//getChildView("BtnOwner")->setEnabled(TRUE); // <FS:Ansariel> Avatar names often not showing on first open
   1.118  		getChildView("LabelOwnerTitle")->setEnabled(TRUE);
   1.119  		getChildView("LabelOwnerName")->setEnabled(TRUE);
   1.120 -		getChild<LLUICtrl>("LabelOwnerName")->setValue(name);
   1.121 +		//getChild<LLUICtrl>("LabelOwnerName")->setValue(name); // <FS:Ansariel> Avatar names often not showing on first open
   1.122  	}
   1.123  	else
   1.124  	{
   1.125 @@ -979,6 +991,46 @@
   1.126  	}
   1.127  }
   1.128  
   1.129 +// <FS:Ansariel> Avatar names often not showing on first open
   1.130 +void LLFloaterProperties::onCreatorNameCallback(const LLUUID& av_id, const LLAvatarName& av_name, const LLPermissions& perm)
   1.131 +{
   1.132 +	bool enabled = true;
   1.133 +	std::string name = av_name.getUserName();
   1.134 +	// If the object creator matches the object owner we need to anonymize the creator field as well
   1.135 +	if ( (!RlvActions::canShowName(RlvActions::SNC_DEFAULT, av_id)) &&
   1.136 +		    ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == av_id) ) || (RlvUtil::isNearbyAgent(av_id)) ) )
   1.137 +	{
   1.138 +		enabled = false;
   1.139 +		name = RlvStrings::getAnonym(av_name);
   1.140 +	}
   1.141 +	getChild<LLUICtrl>("LabelCreatorName")->setValue(name);
   1.142 +	childSetEnabled("BtnCreator", enabled);
   1.143 +}
   1.144 +
   1.145 +void LLFloaterProperties::onOwnerNameCallback(const LLUUID& av_id, const LLAvatarName& av_name)
   1.146 +{
   1.147 +	bool fRlvCanShowOwner = true;
   1.148 +	std::string name = av_name.getUserName();
   1.149 +	if (RlvActions::isRlvEnabled())
   1.150 +	{
   1.151 +		fRlvCanShowOwner = RlvActions::canShowName(RlvActions::SNC_DEFAULT, av_id);
   1.152 +		if (!fRlvCanShowOwner)
   1.153 +		{
   1.154 +			name = RlvStrings::getAnonym(av_name);
   1.155 +		}
   1.156 +	}
   1.157 +
   1.158 +	getChild<LLUICtrl>("LabelOwnerName")->setValue(name);
   1.159 +	getChildView("BtnOwner")->setEnabled(fRlvCanShowOwner);
   1.160 +}
   1.161 +
   1.162 +void LLFloaterProperties::onGroupOwnerNameCallback(const std::string& name)
   1.163 +{
   1.164 +	getChild<LLUICtrl>("LabelOwnerName")->setValue(name);
   1.165 +	getChildView("BtnOwner")->setEnabled(TRUE);
   1.166 +}
   1.167 +// </FS:Ansariel>
   1.168 +
   1.169  ///----------------------------------------------------------------------------
   1.170  /// LLMultiProperties
   1.171  ///----------------------------------------------------------------------------
     2.1 --- a/indra/newview/llfloaterproperties.h	Thu Dec 07 11:10:51 2017 +0200
     2.2 +++ b/indra/newview/llfloaterproperties.h	Fri Dec 08 10:11:13 2017 +0100
     2.3 @@ -44,6 +44,11 @@
     2.4  
     2.5  class LLPropertiesObserver;
     2.6  
     2.7 +// <FS:Ansariel> Avatar names often not showing on first open
     2.8 +class LLAvatarName;
     2.9 +class LLPermissions;
    2.10 +// </FS:Ansariel>
    2.11 +
    2.12  class LLFloaterProperties : public LLFloater
    2.13  {
    2.14  public:
    2.15 @@ -90,6 +95,15 @@
    2.16  	BOOL mDirty;
    2.17  
    2.18  	LLPropertiesObserver* mPropertiesObserver;
    2.19 +
    2.20 +	// <FS:Ansariel> Avatar names often not showing on first open
    2.21 +	boost::signals2::connection mCreatorNameCbConnection;
    2.22 +	boost::signals2::connection mOwnerNameCbConnection;
    2.23 +	boost::signals2::connection mGroupOwnerNameCbConnection;
    2.24 +	void onCreatorNameCallback(const LLUUID& av_id, const LLAvatarName& av_name, const LLPermissions& perm);
    2.25 +	void onOwnerNameCallback(const LLUUID& av_id, const LLAvatarName& av_name);
    2.26 +	void onGroupOwnerNameCallback(const std::string& name);
    2.27 +	// </FS:Ansariel>
    2.28  };
    2.29  
    2.30  class LLMultiProperties : public LLMultiFloater

mercurial