From 33dfd860ecd29790b4c43c28f52b185c98ad791d Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Mon, 27 Jul 2015 18:46:29 +0300
Subject: [PATCH] MAINT-5439 FIXED Gesture will not deactivate by using the
 deactivate button in inventory drop down menu

---
 indra/newview/llappearancemgr.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 142a3250c8..a0c3868dc6 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -3821,9 +3821,17 @@ void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove)
 		const LLUUID& id_to_remove = *it;
 		const LLUUID& linked_item_id = gInventory.getLinkedItemID(id_to_remove);
 		LLViewerInventoryItem *item = gInventory.getItem(linked_item_id);
-		if (item && item->getType() == LLAssetType::AT_OBJECT)
+		if (item)
 		{
-			LL_DEBUGS("Avatar") << "ATT removing attachment " << item->getName() << " id " << item->getUUID() << LL_ENDL;
+			if (item->getType() == LLAssetType::AT_OBJECT)
+			{
+				LL_DEBUGS("Avatar") << "ATT removing attachment " << item->getName() << " id " << item->getUUID() << LL_ENDL;
+			}
+			if (item->getType() == LLAssetType::AT_GESTURE && LLGestureMgr::instance().isGestureActive(item->getLinkedUUID()))
+			{
+				// deactivate gesture before removing link
+				LLGestureMgr::instance().deactivateGesture(item->getLinkedUUID());
+			}
 		}
 		removeCOFItemLinks(linked_item_id, cb);
 		addDoomedTempAttachment(linked_item_id);
-- 
GitLab