From 946bdc1ee352618f0d333292272aceb48b6d8dd8 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Mon, 8 Aug 2022 22:38:56 +0300
Subject: [PATCH] SL-14556 Profile floater does not update after a name change

---
 indra/newview/llfloaterprofile.cpp    | 14 ++++++++++++++
 indra/newview/llfloaterprofile.h      |  1 +
 indra/newview/llpanelprofile.cpp      | 13 +++++++++++++
 indra/newview/llpanelprofile.h        |  2 ++
 indra/newview/llviewerdisplayname.cpp |  8 ++++++++
 5 files changed, 38 insertions(+)

diff --git a/indra/newview/llfloaterprofile.cpp b/indra/newview/llfloaterprofile.cpp
index a4a9fe84106..624075e9fde 100644
--- a/indra/newview/llfloaterprofile.cpp
+++ b/indra/newview/llfloaterprofile.cpp
@@ -137,6 +137,20 @@ bool LLFloaterProfile::isPickTabSelected()
     return mPanelProfile->isPickTabSelected();
 }
 
+void LLFloaterProfile::refreshName()
+{
+    if (!mNameCallbackConnection.connected())
+    {
+        mNameCallbackConnection = LLAvatarNameCache::get(mAvatarId, boost::bind(&LLFloaterProfile::onAvatarNameCache, this, _1, _2));
+    }
+
+    LLPanelProfileSecondLife *panel = findChild<LLPanelProfileSecondLife>("panel_profile_secondlife");
+    if (panel)
+    {
+        panel->refreshName();
+    }
+}
+
 void LLFloaterProfile::showClassified(const LLUUID& classified_id, bool edit)
 {
     mPanelProfile->showClassified(classified_id, edit);
diff --git a/indra/newview/llfloaterprofile.h b/indra/newview/llfloaterprofile.h
index 36023077d3e..c2b90a1dce5 100644
--- a/indra/newview/llfloaterprofile.h
+++ b/indra/newview/llfloaterprofile.h
@@ -49,6 +49,7 @@ class LLFloaterProfile : public LLFloater
     void createPick(const LLPickData &data);
     void showPick(const LLUUID& pick_id = LLUUID::null);
     bool isPickTabSelected();
+    void refreshName();
 
     void showClassified(const LLUUID& classified_id = LLUUID::null, bool edit = false);
 
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index 195244ea226..2f4da59cfd1 100644
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -973,6 +973,14 @@ void LLPanelProfileSecondLife::updateData()
     }
 }
 
+void LLPanelProfileSecondLife::refreshName()
+{
+    if (!mAvatarNameCacheConnection.connected())
+    {
+        mAvatarNameCacheConnection = LLAvatarNameCache::get(getAvatarId(), boost::bind(&LLPanelProfileSecondLife::onAvatarNameCache, this, _1, _2));
+    }
+}
+
 void LLPanelProfileSecondLife::resetData()
 {
     resetLoading();
@@ -2576,6 +2584,11 @@ void LLPanelProfile::updateData()
     }
 }
 
+void LLPanelProfile::refreshName()
+{
+    mPanelSecondlife->refreshName();
+}
+
 void LLPanelProfile::createPick(const LLPickData &data)
 {
     mTabContainer->selectTabPanel(mPanelPicks);
diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h
index b363bd3fd2b..41533c137f1 100644
--- a/indra/newview/llpanelprofile.h
+++ b/indra/newview/llpanelprofile.h
@@ -96,6 +96,7 @@ class LLPanelProfileSecondLife
 	 * Sends update data request to server.
 	 */
 	void updateData() override;
+    void refreshName();
 
 	void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
 
@@ -368,6 +369,7 @@ class LLPanelProfile
     BOOL postBuild() override;
 
     void updateData() override;
+    void refreshName();
 
     void onOpen(const LLSD& key) override;
 
diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp
index d444d476242..cec08c4f152 100644
--- a/indra/newview/llviewerdisplayname.cpp
+++ b/indra/newview/llviewerdisplayname.cpp
@@ -30,6 +30,8 @@
 
 // viewer includes
 #include "llagent.h"
+#include "llfloaterprofile.h"
+#include "llfloaterreg.h"
 #include "llviewerregion.h"
 #include "llvoavatar.h"
 
@@ -206,6 +208,12 @@ class LLDisplayNameUpdate : public LLHTTPNode
 		{
 			LLViewerDisplayName::sNameChangedSignal();
 		}
+
+        LLFloaterProfile* profile_floater = dynamic_cast<LLFloaterProfile*>(LLFloaterReg::findInstance("profile", LLSD().with("id", agent_id)));
+        if (profile_floater)
+        {
+            profile_floater->refreshName();
+        }
 	}
 };
 
-- 
GitLab