From b0ea6f5e0aed993b0f05de6bf7d03d81b520a5d0 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Wed, 13 Mar 2024 22:15:56 +0200
Subject: viewer#945 Some worn items are missing from Avatar floater's Outfits
 tab

---
 indra/newview/llaisapi.cpp                        |  2 --
 indra/newview/llinventorymodelbackgroundfetch.cpp | 17 +++++++++++++++++
 indra/newview/lloutfitslist.cpp                   | 12 ++----------
 3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp
index 17e1a27934..68b07a46c4 100644
--- a/indra/newview/llaisapi.cpp
+++ b/indra/newview/llaisapi.cpp
@@ -1385,8 +1385,6 @@ void AISUpdate::parseCategory(const LLSD& category_map, S32 depth)
                      && curr_cat->getVersion() > LLViewerInventoryCategory::VERSION_UNKNOWN
                      && version > curr_cat->getVersion())
             {
-                // Potentially should new_cat->setVersion(unknown) here,
-                // but might be waiting for a callback that would increment
                 LL_DEBUGS("Inventory") << "Category " << category_id
                     << " is stale. Known version: " << curr_cat->getVersion()
                     << " server version: " << version << LL_ENDL;
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index 1f410bea10..c36b4b9726 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -30,6 +30,7 @@
 #include "llaisapi.h"
 #include "llagent.h"
 #include "llappviewer.h"
+#include "llappearancemgr.h"
 #include "llcallbacklist.h"
 #include "llinventorymodel.h"
 #include "llinventorypanel.h"
@@ -423,6 +424,22 @@ void LLInventoryModelBackgroundFetch::fetchCOF(nullary_func_t callback)
                          callback();
                          LLUUID cat_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT);
                          LLInventoryModelBackgroundFetch::getInstance()->onAISFolderCalback(cat_id, id, FT_DEFAULT);
+
+                         if (id.notNull())
+                         {
+                             // COF might have fetched base outfit folder through a link, but it hasn't
+                             // fetched base outfit's content, which doesn't nessesary match COF,
+                             // so make sure it's up to date
+                             LLUUID baseoutfit_id = LLAppearanceMgr::getInstance()->getBaseOutfitUUID();
+                             if (baseoutfit_id.notNull())
+                             {
+                                 LLViewerInventoryCategory* cat = gInventory.getCategory(baseoutfit_id);
+                                 if (!cat || cat->getVersion() == LLViewerInventoryCategory::VERSION_UNKNOWN)
+                                 {
+                                     LLInventoryModelBackgroundFetch::getInstance()->fetchFolderAndLinks(baseoutfit_id, no_op);
+                                 }
+                             }
+                         }
                      });
 
     // start idle loop to track completion
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index 5c7792b0df..ba714cbedd 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -885,18 +885,10 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id)
         ++items_iter)
     {
         LLViewerInventoryCategory *cat = gInventory.getCategory(*items_iter);
-        if (!cat)
+        if (cat)
         {
-            LLInventoryObject* obj = gInventory.getObject(*items_iter);
-            if(!obj || (obj->getType() != LLAssetType::AT_CATEGORY))
-            {
-                return;
-            }
-            cat = (LLViewerInventoryCategory*)obj;
+            updateChangedCategoryName(cat, cat->getName());
         }
-        std::string name = cat->getName();
-
-        updateChangedCategoryName(cat, name);
     }
 
     sortOutfits();
-- 
cgit v1.2.3