From a3d8338cdcf73b17f6cec4f07916560477d933a6 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Fri, 12 Feb 2010 13:12:26 -0500
Subject: [PATCH] For EXT-5259: Major regression in load time for new users
 from 1.23 to 2.0.  Moved autopopulate to after avatar appearance resolves

---
 indra/newview/llagentwearables.cpp |  2 ++
 indra/newview/llappearancemgr.cpp  | 14 ++++++++++++++
 indra/newview/llappearancemgr.h    |  3 +++
 indra/newview/llstartup.cpp        | 11 -----------
 indra/newview/llvoavatar.cpp       |  7 +++++++
 5 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 6620780b273..e8e347c82a1 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -2143,6 +2143,8 @@ void LLAgentWearables::updateServer()
 
 void LLAgentWearables::populateMyOutfitsFolder(void)
 {	
+	llinfos << "BAP starting populate" << llendl;
+
 	LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch();
 	
 	// Get the complete information on the items in the inventory and 
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index aad39854e43..8a646bd626e 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1307,6 +1307,20 @@ void LLAppearanceManager::updateIsDirty()
 	}
 }
 
+void LLAppearanceManager::onFirstFullyVisible()
+{
+	// If this is the very first time the user has logged into viewer2+ (from a legacy viewer, or new account)
+	// then auto-populate outfits from the library into the My Outfits folder.
+	static bool check_populate_my_outfits = true;
+	if (check_populate_my_outfits && 
+		(LLInventoryModel::getIsFirstTimeInViewer2() 
+		 || gSavedSettings.getBOOL("MyOutfitsAutofill")))
+	{
+		gAgentWearables.populateMyOutfitsFolder();
+	}
+	check_populate_my_outfits = false;
+}
+
 //#define DUMP_CAT_VERBOSE
 
 void LLAppearanceManager::dumpCat(const LLUUID& cat_id, const std::string& msg)
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index 5fdff45735c..28b51ee0f67 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -113,6 +113,9 @@ class LLAppearanceManager: public LLSingleton<LLAppearanceManager>
 	// should only be necessary to do on initial login.
 	void updateIsDirty();
 
+	// Called when self avatar is first fully visible.
+	void onFirstFullyVisible();
+	
 protected:
 	LLAppearanceManager();
 	~LLAppearanceManager();
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 171b441b2b2..cbcd9640dd5 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1891,17 +1891,6 @@ bool idle_startup()
 			}
 		}
 		
-		// If this is the very first time the user has logged into viewer2+ (from a legacy viewer, or new account)
-		// then auto-populate outfits from the library into the My Outfits folder.
-		static bool check_populate_my_outfits = true;
-		if (check_populate_my_outfits && 
-			(LLInventoryModel::getIsFirstTimeInViewer2() 
-			 || gSavedSettings.getBOOL("MyOutfitsAutofill")))
-		{
-			gAgentWearables.populateMyOutfitsFolder();
-		}
-		check_populate_my_outfits = false;
-
 		return TRUE;
 	}
 
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 9b91d5abfa0..bcf5cf3f6c3 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2535,6 +2535,13 @@ void LLVOAvatar::idleUpdateLoadingEffect()
 		if (isFullyLoaded() && isSelf())
 		{
 			llwarns << "BAP self isFullyLoaded" << llendl;
+
+			static bool first_fully_visible = true;
+			if (first_fully_visible)
+			{
+				first_fully_visible = false;
+				LLAppearanceManager::instance().onFirstFullyVisible();
+			}
 		}
 		if (isFullyLoaded())
 		{
-- 
GitLab