summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-03-13 22:15:56 +0200
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-03-14 17:19:55 +0200
commit56c88b83435facd5023b8781a59ade12dc865e15 (patch)
treef1e499268a3403cc3fe62c5a4d652b5d792d6746
parent2f452d06e6964b0edf26b0b3f6eaa156e3fa2d48 (diff)
SL-20288 Fix renaming
getChangedIDs is only accurate in scope of observer's callback, don't use it onIdle. getObject call made no sense, item was warrantied to be LLViewerInventoryItem and would only be AT_CATEGORY if it is a link, making the following cast to a category dangerous
-rw-r--r--indra/newview/lloutfitslist.cpp33
-rw-r--r--indra/newview/lloutfitslist.h2
2 files changed, 21 insertions, 14 deletions
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index 27d73fc4ae..352d59a9c2 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -790,7 +790,7 @@ void LLOutfitListBase::onOpen(const LLSD& info)
// Start observing changes in "My Outfits" category.
mCategoriesObserver->addCategory(outfits,
- boost::bind(&LLOutfitListBase::refreshList, this, outfits));
+ boost::bind(&LLOutfitListBase::observerCallback, this, outfits));
//const LLUUID cof = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT);
// Start observing changes in Current Outfit category.
@@ -810,6 +810,13 @@ void LLOutfitListBase::onOpen(const LLSD& info)
}
}
+void LLOutfitListBase::observerCallback(const LLUUID& category_id)
+{
+ const LLInventoryModel::changed_items_t& changed_items = gInventory.getChangedIDs();
+ mChangedItems.insert(changed_items.begin(), changed_items.end());
+ refreshList(category_id);
+}
+
void LLOutfitListBase::refreshList(const LLUUID& category_id)
{
bool wasNull = mRefreshListState.CategoryUUID.isNull();
@@ -905,24 +912,22 @@ void LLOutfitListBase::onIdleRefreshList()
// Get changed items from inventory model and update outfit tabs
// which might have been renamed.
- const LLInventoryModel::changed_items_t& changed_items = gInventory.getChangedIDs();
- for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin();
- items_iter != changed_items.end();
- ++items_iter)
+ while (!mChangedItems.empty())
{
+ std::set<LLUUID>::const_iterator items_iter = mChangedItems.begin();
LLViewerInventoryCategory *cat = gInventory.getCategory(*items_iter);
- if (!cat)
+ mChangedItems.erase(items_iter);
+
+ // Links aren't supposed to be allowed here, check only cats
+ if (cat)
{
- LLInventoryObject* obj = gInventory.getObject(*items_iter);
- if (!obj || (obj->getType() != LLAssetType::AT_CATEGORY))
- {
- break;
- }
- cat = (LLViewerInventoryCategory*)obj;
+ std::string name = cat->getName();
+ updateChangedCategoryName(cat, name);
}
- std::string name = cat->getName();
- updateChangedCategoryName(cat, name);
+ curent_time = LLTimer::getTotalSeconds();
+ if (curent_time >= end_time)
+ return;
}
sortOutfits();
diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h
index 43c3ba75b5..980b9c3970 100644
--- a/indra/newview/lloutfitslist.h
+++ b/indra/newview/lloutfitslist.h
@@ -109,6 +109,7 @@ public:
virtual bool getHasExpandableFolders() = 0;
protected:
+ void observerCallback(const LLUUID& category_id);
virtual LLOutfitListGearMenuBase* createGearMenu() = 0;
virtual void onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id) = 0;
virtual void onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid) = 0;
@@ -127,6 +128,7 @@ protected:
uuid_vec_t::const_iterator AddedIterator;
uuid_vec_t::const_iterator RemovedIterator;
} mRefreshListState;
+ std::set<LLUUID> mChangedItems;
bool mIsInitialized;
LLInventoryCategoriesObserver* mCategoriesObserver;