From 37b04c150792bb3e53a5ba02c6631aa1d0f8686f Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Mon, 21 Dec 2009 14:54:55 -0500
Subject: [PATCH] EXT-3582 : My Outfits populates from library if I delete my
 last outfit

Tracking a "Is this my first time in viewer2.0?" flag and only populating My Outfits folder if it's true.
---
 indra/newview/llagentwearables.cpp |  5 +----
 indra/newview/llinventorymodel.cpp | 17 +++++++++++++++++
 indra/newview/llinventorymodel.h   | 11 +++++++++--
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 454e547155e..79948abefd4 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -875,9 +875,6 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
 	LLUUID agent_id;
 	gMessageSystem->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 
-	const BOOL is_first_time_in_viewer2_0 = (gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, FALSE) == LLUUID::null);
-
-
 	LLVOAvatar* avatar = gAgent.getAvatarObject();
 	if (avatar && (agent_id == avatar->getID()))
 	{
@@ -957,7 +954,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
 			gInventory.addObserver(outfit);
 		}
 		
-		if (is_first_time_in_viewer2_0)
+		if (LLInventoryModel::getIsFirstTimeInViewer2())
 			gAgentWearables.populateMyOutfitsFolder();
 	}
 }
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 0a8108899ae..26a81ab0849 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -67,6 +67,7 @@ F32  LLInventoryModel::sMaxTimeBetweenFetches = 10.f;
 BOOL LLInventoryModel::sTimelyFetchPending = FALSE;
 LLFrameTimer LLInventoryModel::sFetchTimer;
 S16 LLInventoryModel::sBulkFetchCount = 0;
+BOOL LLInventoryModel::sFirstTimeInViewer2 = TRUE;
 
 // Increment this if the inventory contents change in a non-backwards-compatible way.
 // For viewer 2, the addition of link items makes a pre-viewer-2 cache incorrect.
@@ -2614,6 +2615,9 @@ void LLInventoryModel::buildParentChildMap()
 			notifyObservers();
 		}
 	}
+
+	const BOOL COF_exists = (findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, FALSE) != LLUUID::null);
+	sFirstTimeInViewer2 = !COF_exists;
 }
 
 struct LLUUIDAndName
@@ -3530,6 +3534,19 @@ void LLInventoryModel::setLibraryOwnerID(const LLUUID& val)
 	mLibraryOwnerID = val;
 }
 
+// static
+BOOL LLInventoryModel::getIsFirstTimeInViewer2()
+{
+	// Do not call this before parentchild map is built.
+	if (!gInventory.mIsAgentInvUsable)
+	{
+		llwarns << "Parent Child Map not yet built; guessing as first time in viewer2." << llendl;
+		return TRUE;
+	}
+
+	return sFirstTimeInViewer2;
+}
+
 //----------------------------------------------------------------------------
 
 // *NOTE: DEBUG functionality
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h
index 27bbca493da..29f2aec89ee 100644
--- a/indra/newview/llinventorymodel.h
+++ b/indra/newview/llinventorymodel.h
@@ -499,9 +499,9 @@ class LLInventoryModel
 	// *NOTE: DEBUG functionality
 	void dumpInventory() const;
 
-	////////////////////////////////////////////////////////////////////////////////
-	// Bulk / Background Fetch
 
+	////////////////////////////////////////////////////////////////////////////////
+	// Bulk fetch
 public:
 	// Start and stop background breadth-first fetching of inventory contents.
 	// This gets triggered when performing a filter-search
@@ -525,6 +525,13 @@ class LLInventoryModel
 	// completing the fetch once per session should be sufficient
 	static BOOL sBackgroundFetchActive;
 	static S16 sBulkFetchCount;
+
+	////////////////////////////////////////////////////////////////////////////////
+	// Login status
+public:
+	static BOOL getIsFirstTimeInViewer2();
+private:
+	static BOOL sFirstTimeInViewer2;
 };
 
 // a special inventory model for the agent
-- 
GitLab