From c0f28ae36261cc31d6412c42c05d1b7719a2c04b Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Thu, 18 Mar 2021 22:45:38 +0200
Subject: [PATCH] SL-14927 Some avatar names not resolving

---
 doc/contributions.txt            |  5 +++--
 indra/newview/llagent.cpp        | 15 +++++++--------
 indra/newview/llagent.h          |  2 +-
 indra/newview/llappviewer.cpp    |  7 +++----
 indra/newview/llappviewer.h      |  3 ++-
 indra/newview/llenvironment.cpp  |  2 +-
 indra/newview/llviewerregion.cpp |  4 ++--
 indra/newview/llviewerregion.h   |  2 +-
 indra/newview/llwlhandlers.cpp   |  2 +-
 9 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index bbdfaf655dd..2b77b582228 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -263,10 +263,11 @@ Benja Kepler
 Benjamin Bigdipper
 Beq Janus
 	BUG-227094
-Beth Walcher
-Beq Janus
 	SL-10288
 	SL-13583
+	SL-14766
+	SL-14927
+Beth Walcher
 Bezilon Kasei
 Biancaluce Robbiani
 	CT-225
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 5c00cfc783e..baf0acc94b4 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -879,13 +879,12 @@ boost::signals2::connection LLAgent::addParcelChangedCallback(parcel_changed_cal
 }
 
 // static
-void LLAgent::capabilityReceivedCallback(const LLUUID &region_id)
+void LLAgent::capabilityReceivedCallback(const LLUUID &region_id, LLViewerRegion *regionp)
 {
-    LLViewerRegion* region = gAgent.getRegion();
-    if (region && region->getRegionID() == region_id)
+    if (regionp && regionp->getRegionID() == region_id)
     {
-        region->requestSimulatorFeatures();
-        LLAppViewer::instance()->updateNameLookupUrl();
+        regionp->requestSimulatorFeatures();
+        LLAppViewer::instance()->updateNameLookupUrl(regionp);
     }
 }
 
@@ -936,7 +935,7 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
             if (regionp->capabilitiesReceived())
             {
                 regionp->requestSimulatorFeatures();
-                LLAppViewer::instance()->updateNameLookupUrl();
+                LLAppViewer::instance()->updateNameLookupUrl(regionp);
             }
             else
             {
@@ -962,11 +961,11 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
 
             if (regionp->capabilitiesReceived())
             {
-                LLAppViewer::instance()->updateNameLookupUrl();
+                LLAppViewer::instance()->updateNameLookupUrl(regionp);
             }
             else
             {
-                regionp->setCapabilitiesReceivedCallback([](const LLUUID &region_id) {LLAppViewer::instance()->updateNameLookupUrl(); });
+                regionp->setCapabilitiesReceivedCallback([](const LLUUID &region_id, LLViewerRegion* regionp) {LLAppViewer::instance()->updateNameLookupUrl(regionp); });
             }
 		}
 
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index d46c99db8cc..f5ca42af5b2 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -254,7 +254,7 @@ class LLAgent : public LLOldEvents::LLObservable
 	boost::signals2::connection     addParcelChangedCallback(parcel_changed_callback_t);
 
 private:
-	static void capabilityReceivedCallback(const LLUUID &region_id);
+	static void capabilityReceivedCallback(const LLUUID &region_id, LLViewerRegion *regionp);
 
 	typedef boost::signals2::signal<void()> parcel_changed_signal_t;
 	parcel_changed_signal_t		mParcelChangedSignal;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 7c2f622abd1..fe2da2f9897 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -5226,10 +5226,9 @@ void LLAppViewer::sendLogoutRequest()
 	}
 }
 
-void LLAppViewer::updateNameLookupUrl()
+void LLAppViewer::updateNameLookupUrl(const LLViewerRegion * regionp)
 {
-    LLViewerRegion* region = gAgent.getRegion();
-    if (!region || !region->capabilitiesReceived())
+    if (!regionp || !regionp->capabilitiesReceived())
     {
         return;
     }
@@ -5238,7 +5237,7 @@ void LLAppViewer::updateNameLookupUrl()
     bool had_capability = LLAvatarNameCache::getInstance()->hasNameLookupURL();
     std::string name_lookup_url;
     name_lookup_url.reserve(128); // avoid a memory allocation below
-    name_lookup_url = region->getCapability("GetDisplayNames");
+    name_lookup_url = regionp->getCapability("GetDisplayNames");
     bool have_capability = !name_lookup_url.empty();
     if (have_capability)
     {
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 6db45583eb7..95e93be5726 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -57,6 +57,7 @@ class LLImageDecodeThread;
 class LLTextureFetch;
 class LLWatchdogTimeout;
 class LLViewerJoystick;
+class LLViewerRegion;
 
 extern LLTrace::BlockTimerStatHandle FTM_FRAME;
 
@@ -209,7 +210,7 @@ class LLAppViewer : public LLApp
 	// llcorehttp init/shutdown/config information.
 	LLAppCoreHttp & getAppCoreHttp()			{ return mAppCoreHttp; }
 
-    void updateNameLookupUrl();
+    void updateNameLookupUrl(const LLViewerRegion* regionp);
 
 protected:
 	virtual bool initWindow(); // Initialize the viewer's window.
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index b6f120e6444..431ca4fc050 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -1029,7 +1029,7 @@ void LLEnvironment::onRegionChange()
     }
     if (!cur_region->capabilitiesReceived())
     {
-        cur_region->setCapabilitiesReceivedCallback([](const LLUUID &region_id) {  LLEnvironment::instance().requestRegion(); });
+        cur_region->setCapabilitiesReceivedCallback([](const LLUUID &region_id, LLViewerRegion* regionp) {  LLEnvironment::instance().requestRegion(); });
         return;
     }
     requestRegion();
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 2fde4fe49c8..f007aefc704 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2241,7 +2241,7 @@ void LLViewerRegion::setSimulatorFeaturesReceived(bool received)
 	mSimulatorFeaturesReceived = received;
 	if (received)
 	{
-		mSimulatorFeaturesReceivedSignal(getRegionID());
+		mSimulatorFeaturesReceivedSignal(getRegionID(), this);
 		mSimulatorFeaturesReceivedSignal.disconnect_all_slots();
 	}
 }
@@ -3183,7 +3183,7 @@ void LLViewerRegion::setCapabilitiesReceived(bool received)
 	// so that they can safely use getCapability().
 	if (received)
 	{
-		mCapabilitiesReceivedSignal(getRegionID());
+		mCapabilitiesReceivedSignal(getRegionID(), this);
 
 		LLFloaterPermsDefault::sendInitialPerms();
 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index dfd8c64f766..fcbf56c81f1 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -94,7 +94,7 @@ class LLViewerRegion: public LLCapabilityProvider // implements this interface
 		NUM_PARTITIONS
 	} eObjectPartitions;
 
-	typedef boost::signals2::signal<void(const LLUUID& region_id)> caps_received_signal_t;
+	typedef boost::signals2::signal<void(const LLUUID& region_id, LLViewerRegion* regionp)> caps_received_signal_t;
 
 	LLViewerRegion(const U64 &handle,
 				   const LLHost &host,
diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp
index 730aa3774ff..d55e1b7cd36 100644
--- a/indra/newview/llwlhandlers.cpp
+++ b/indra/newview/llwlhandlers.cpp
@@ -51,7 +51,7 @@ bool LLEnvironmentRequest::initiate(LLEnvironment::environment_apply_fn cb)
 	if (!cur_region->capabilitiesReceived())
 	{
 		LL_INFOS("WindlightCaps") << "Deferring windlight settings request until we've got region caps" << LL_ENDL;
-        cur_region->setCapabilitiesReceivedCallback([cb](const LLUUID &region_id) { LLEnvironmentRequest::onRegionCapsReceived(region_id, cb); });
+        cur_region->setCapabilitiesReceivedCallback([cb](const LLUUID &region_id, LLViewerRegion* regionp) { LLEnvironmentRequest::onRegionCapsReceived(region_id, cb); });
 		return false;
 	}
 
-- 
GitLab