From 3c4cf92932fb8215f496e4100cfa3b6f3a4372b4 Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Tue, 26 Mar 2019 16:13:44 +0200
Subject: [PATCH] SL-10799 [Legacy Profiles] Autoadjust texture during image
 selection

---
 indra/newview/llpanelprofile.cpp | 24 ++++++++++++++++++++++--
 indra/newview/llpanelprofile.h   |  1 +
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index b03fcabd924..d03d3f59b8d 100644
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -281,6 +281,7 @@ BOOL LLPanelProfileSecondLife::postBuild()
     mUnblockButton->setCommitCallback(boost::bind(&LLPanelProfileSecondLife::onClickToggleBlock, this));
     mGroupInviteButton->setCommitCallback(boost::bind(&LLPanelProfileSecondLife::onGroupInvite,this));
     mDisplayNameButton->setCommitCallback(boost::bind(&LLPanelProfileSecondLife::onClickSetName, this));
+    mSecondLifePic->setCommitCallback(boost::bind(&LLPanelProfileSecondLife::onCommitTexture, this));
 
     LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable;
     enable.add("Profile.EnableCall",                [this](LLUICtrl*, const LLSD&) { return mVoiceStatus; });
@@ -488,7 +489,7 @@ void LLPanelProfileSecondLife::fillCommonData(const LLAvatarData* avatar_data)
 
     //Don't bother about boost level, picker will set it
     LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTexture(avatar_data->image_id);
-    if (imagep->getHeight())
+    if (imagep->getFullHeight())
     {
         onImageLoaded(true, imagep);
     }
@@ -581,7 +582,7 @@ void LLPanelProfileSecondLife::onGroupInvite()
 void LLPanelProfileSecondLife::onImageLoaded(BOOL success, LLViewerFetchedTexture *imagep)
 {
     LLRect imageRect = mSecondLifePicLayout->getRect();
-    if (!success || imagep->getWidth() == imagep->getHeight())
+    if (!success || imagep->getFullWidth() == imagep->getFullHeight())
     {
         mSecondLifePicLayout->reshape(imageRect.getHeight(), imageRect.getHeight());
     }
@@ -742,6 +743,25 @@ void LLPanelProfileSecondLife::onClickSetName()
     LLFirstUse::setDisplayName(false);
 }
 
+void LLPanelProfileSecondLife::onCommitTexture()
+{
+    LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTexture(mSecondLifePic->getImageAssetID());
+    if (imagep->getFullHeight())
+    {
+        onImageLoaded(true, imagep);
+    }
+    else
+    {
+        imagep->setLoadedCallback(onImageLoaded,
+            MAX_DISCARD_LEVEL,
+            FALSE,
+            FALSE,
+            new LLHandle<LLPanel>(getHandle()),
+            NULL,
+            FALSE);
+    }
+}
+
 void LLPanelProfileSecondLife::onAvatarNameCacheSetName(const LLUUID& agent_id, const LLAvatarName& av_name)
 {
     if (av_name.getDisplayName().empty())
diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h
index f346dcf937d..4ed09761df5 100644
--- a/indra/newview/llpanelprofile.h
+++ b/indra/newview/llpanelprofile.h
@@ -177,6 +177,7 @@ class LLPanelProfileSecondLife
 private:
     /*virtual*/ void updateButtons();
 	void onClickSetName();
+	void onCommitTexture();
 	void onAvatarNameCacheSetName(const LLUUID& id, const LLAvatarName& av_name);
 
 private:
-- 
GitLab