From b3493dcaeeb49ca503cb889cbe9e95a63f8eed56 Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Wed, 23 Nov 2016 19:28:54 +0200
Subject: [PATCH] MAINT-6951 Fixed Appearance panel causing camera movement
 regardless of circumstance.

---
 indra/newview/llsidepanelappearance.cpp | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index f07f0ed86c7..a32ed258f84 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -383,12 +383,22 @@ void LLSidepanelAppearance::toggleOutfitEditPanel(BOOL visible, BOOL disable_cam
 
 void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLViewerWearable *wearable, BOOL disable_camera_switch)
 {
-	if (!mEditWearable || ((mEditWearable->getWearable() == wearable) && mEditWearable->getVisible() == visible))
+	if (!mEditWearable)
 	{
-		// visibility isn't changing, hence nothing to do
 		return;
 	}
 
+	if (mEditWearable->getVisible() == visible && (!visible || mEditWearable->getWearable() != wearable))
+	{
+		// visibility isn't changing and panel doesn't need an update, hence nothing to do
+		return;
+	}
+
+	// If we're just switching between outfit and wearable editing or updating item,
+	// don't end customization and don't switch camera
+	// Don't end customization and don't switch camera without visibility change
+	BOOL change_state = !disable_camera_switch && mEditWearable->getVisible() != visible;
+
 	if (!wearable)
 	{
 		wearable = gAgentWearables.getViewerWearable(LLWearableType::WT_SHAPE, 0);
@@ -403,8 +413,8 @@ void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLViewerWearab
 
 	if (visible)
 	{
-		LLVOAvatarSelf::onCustomizeStart(disable_camera_switch);
-		mEditWearable->setWearable(wearable, disable_camera_switch);
+		LLVOAvatarSelf::onCustomizeStart(!change_state);
+		mEditWearable->setWearable(wearable, !change_state);
 		mEditWearable->onOpen(LLSD()); // currently no-op, just for consistency
 	}
 	else
@@ -412,9 +422,9 @@ void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLViewerWearab
 		// Save changes if closing.
 		mEditWearable->saveChanges();
 		LLAppearanceMgr::getInstance()->updateIsDirty();
-		if (!disable_camera_switch)   // if we're just switching between outfit and wearable editing, don't end customization.
+		if (change_state)
 		{
-			LLVOAvatarSelf::onCustomizeEnd(disable_camera_switch);
+			LLVOAvatarSelf::onCustomizeEnd(!change_state);
 		}
 	}
 }
-- 
GitLab