From af89e86029c3851d1ab11c7f43dce49bf0c70156 Mon Sep 17 00:00:00 2001
From: Rick Pasetto <rick@lindenlab.com>
Date: Thu, 21 Jan 2010 11:17:50 -0800
Subject: [PATCH] FIX EXT-2871 : Use "original texture" id in panelface if the
 current selected texture is a media texture

Review #84 (Richard and Callum)
---
 indra/newview/llpanelface.cpp | 40 ++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index ee0426c7dff..8c5208678e7 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -65,6 +65,7 @@
 #include "llvovolume.h"
 #include "lluictrlfactory.h"
 #include "llpluginclassmedia.h"
+#include "llviewertexturelist.h"
 
 //
 // Methods
@@ -406,14 +407,40 @@ void LLPanelFace::getState()
 			LLUUID id;
 			struct f1 : public LLSelectedTEGetFunctor<LLUUID>
 			{
-				LLUUID get(LLViewerObject* object, S32 te)
+				LLUUID get(LLViewerObject* object, S32 te_index)
 				{
-					LLViewerTexture* image = object->getTEImage(te);
-					return image ? image->getID() : LLUUID::null;
+					LLUUID id;
+					
+					LLViewerTexture* image = object->getTEImage(te_index);
+					if (image) id = image->getID();
+					
+					if (!id.isNull() && LLViewerMedia::textureHasMedia(id))
+					{
+						LLTextureEntry *te = object->getTE(te_index);
+						if (te)
+						{
+							LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL ;
+							if(!tex)
+							{
+								tex = LLViewerFetchedTexture::sDefaultImagep;
+							}
+							if (tex)
+							{
+								id = tex->getID();
+							}
+						}
+					}
+					return id;
 				}
 			} func;
 			identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id );
 
+			if(LLViewerMedia::textureHasMedia(id))
+			{
+				childSetEnabled("textbox autofix",editable);
+				childSetEnabled("button align",editable);
+			}
+			
 			if (identical)
 			{
 				// All selected have the same texture
@@ -444,13 +471,6 @@ void LLPanelFace::getState()
 					}
 				}
 			}
-
-			if(LLViewerMedia::textureHasMedia(id))
-			{
-				childSetEnabled("textbox autofix",editable);
-				childSetEnabled("button align",editable);
-			}
-
 		}
 
 		
-- 
GitLab