From f790036002a49176066ec346e4068dc05aa88357 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Sat, 10 Jul 2010 00:34:36 +0300
Subject: [PATCH] EXT-8190 PARTIAL FIX Fixed loading indicator infinite spins
 upon pressing 'Save' for outfit with non-link items. - Added inventory
 collector functor to select items by their actual type. - Fixed outfit
 "dirtiness" calculation so only link items are checked.

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/728/.

--HG--
branch : product-engine
---
 indra/newview/llappearancemgr.cpp      | 22 +++++++---------------
 indra/newview/llinventoryfunctions.cpp | 13 +++++++++++++
 indra/newview/llinventoryfunctions.h   | 19 +++++++++++++++++++
 3 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 43f6be42b66..562401cd89f 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2179,17 +2179,19 @@ void LLAppearanceMgr::updateIsDirty()
 	}
 	else
 	{
+		LLIsOfAssetType collector = LLIsOfAssetType(LLAssetType::AT_LINK);
+
 		LLInventoryModel::cat_array_t cof_cats;
 		LLInventoryModel::item_array_t cof_items;
-		gInventory.collectDescendents(cof, cof_cats, cof_items,
-									  LLInventoryModel::EXCLUDE_TRASH);
+		gInventory.collectDescendentsIf(cof, cof_cats, cof_items,
+									  LLInventoryModel::EXCLUDE_TRASH, collector);
 
 		LLInventoryModel::cat_array_t outfit_cats;
 		LLInventoryModel::item_array_t outfit_items;
-		gInventory.collectDescendents(base_outfit, outfit_cats, outfit_items,
-									  LLInventoryModel::EXCLUDE_TRASH);
+		gInventory.collectDescendentsIf(base_outfit, outfit_cats, outfit_items,
+									  LLInventoryModel::EXCLUDE_TRASH, collector);
 
-		if(outfit_items.count() != cof_items.count() -1)
+		if(outfit_items.count() != cof_items.count())
 		{
 			// Current outfit folder should have one more item than the outfit folder.
 			// this one item is the link back to the outfit folder itself.
@@ -2197,16 +2199,6 @@ void LLAppearanceMgr::updateIsDirty()
 			return;
 		}
 
-		//getting rid of base outfit folder link to simplify comparison
-		for (LLInventoryModel::item_array_t::iterator it = cof_items.begin(); it != cof_items.end(); ++it)
-		{
-			if (*it == base_outfit_item)
-			{
-				cof_items.erase(it);
-				break;
-			}
-		}
-
 		//"dirty" - also means a difference in linked UUIDs and/or a difference in wearables order (links' descriptions)
 		std::sort(cof_items.begin(), cof_items.end(), sort_by_linked_uuid);
 		std::sort(outfit_items.begin(), outfit_items.end(), sort_by_linked_uuid);
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 2d11337955c..f20acbd016a 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -507,6 +507,19 @@ bool LLIsNotType::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
 	return TRUE;
 }
 
+bool LLIsOfAssetType::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
+{
+	if(mType == LLAssetType::AT_CATEGORY)
+	{
+		if(cat) return TRUE;
+	}
+	if(item)
+	{
+		if(item->getActualType() == mType) return TRUE;
+	}
+	return FALSE;
+}
+
 bool LLIsTypeWithPermissions::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
 {
 	if(mType == LLAssetType::AT_CATEGORY)
diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h
index a6d7fcd956d..4a7721098d1 100644
--- a/indra/newview/llinventoryfunctions.h
+++ b/indra/newview/llinventoryfunctions.h
@@ -174,6 +174,25 @@ class LLIsNotType : public LLInventoryCollectFunctor
 	LLAssetType::EType mType;
 };
 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// Class LLIsOfAssetType
+//
+// Implementation of a LLInventoryCollectFunctor which returns TRUE if
+// the item or category is of asset type passed in during construction.
+// Link types are treated as links, not as the types they point to.
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+class LLIsOfAssetType : public LLInventoryCollectFunctor
+{
+public:
+	LLIsOfAssetType(LLAssetType::EType type) : mType(type) {}
+	virtual ~LLIsOfAssetType() {}
+	virtual bool operator()(LLInventoryCategory* cat,
+							LLInventoryItem* item);
+protected:
+	LLAssetType::EType mType;
+};
+
 class LLIsTypeWithPermissions : public LLInventoryCollectFunctor
 {
 public:
-- 
GitLab