summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/lloutfitslist.cpp89
-rw-r--r--indra/newview/lloutfitslist.h14
2 files changed, 88 insertions, 15 deletions
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index 5c7792b0df..8042b87a44 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -835,7 +835,6 @@ void LLOutfitListBase::onOpen(const LLSD& info)
// arrive.
category->fetch();
refreshList(outfits);
- highlightBaseOutfit();
mIsInitialized = true;
}
@@ -843,6 +842,9 @@ void LLOutfitListBase::onOpen(const LLSD& info)
void LLOutfitListBase::refreshList(const LLUUID& category_id)
{
+ bool wasNull = mRefreshListState.CategoryUUID.isNull();
+ mRefreshListState.CategoryUUID.setNull();
+
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t item_array;
@@ -855,27 +857,81 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id)
LLInventoryModel::EXCLUDE_TRASH,
is_category);
- uuid_vec_t vadded;
- uuid_vec_t vremoved;
+ // Memorize item names for each UUID
+ std::map<LLUUID, std::string> names;
+ for (const LLPointer<LLViewerInventoryCategory>& cat : cat_array)
+ {
+ names.emplace(std::make_pair(cat->getUUID(), cat->getName()));
+ }
+
+ // Fill added and removed items vectors.
+ mRefreshListState.Added.clear();
+ mRefreshListState.Removed.clear();
+ computeDifference(cat_array, mRefreshListState.Added, mRefreshListState.Removed);
+ // Sort added items vector by item name.
+ std::sort(mRefreshListState.Added.begin(), mRefreshListState.Added.end(),
+ [names](const LLUUID& a, const LLUUID& b)
+ {
+ return LLStringUtil::compareDict(names.at(a), names.at(b)) < 0;
+ });
+ // Initialize iterators for added and removed items vectors.
+ mRefreshListState.AddedIterator = mRefreshListState.Added.begin();
+ mRefreshListState.RemovedIterator = mRefreshListState.Removed.begin();
+
+ LL_INFOS() << "added: " << mRefreshListState.Added.size() <<
+ ", removed: " << mRefreshListState.Removed.size() <<
+ ", changed: " << gInventory.getChangedIDs().size() <<
+ LL_ENDL;
+
+ mRefreshListState.CategoryUUID = category_id;
+ if (wasNull)
+ {
+ gIdleCallbacks.addFunction(onIdle, this);
+ }
+}
+
+// static
+void LLOutfitListBase::onIdle(void* userdata)
+{
+ LLOutfitListBase* self = (LLOutfitListBase*)userdata;
+
+ self->onIdleRefreshList();
+}
+
+void LLOutfitListBase::onIdleRefreshList()
+{
+ if (mRefreshListState.CategoryUUID.isNull())
+ return;
- // Create added and removed items vectors.
- computeDifference(cat_array, vadded, vremoved);
+ const F64 MAX_TIME = 0.05f;
+ F64 curent_time = LLTimer::getTotalSeconds();
+ const F64 end_time = curent_time + MAX_TIME;
// Handle added tabs.
- for (uuid_vec_t::const_iterator iter = vadded.begin();
- iter != vadded.end();
- ++iter)
+ while (mRefreshListState.AddedIterator < mRefreshListState.Added.end())
{
- const LLUUID cat_id = (*iter);
+ const LLUUID cat_id = (*mRefreshListState.AddedIterator++);
updateAddedCategory(cat_id);
+
+ curent_time = LLTimer::getTotalSeconds();
+ if (curent_time >= end_time)
+ return;
}
+ mRefreshListState.Added.clear();
+ mRefreshListState.AddedIterator = mRefreshListState.Added.end();
// Handle removed tabs.
- for (uuid_vec_t::const_iterator iter = vremoved.begin(); iter != vremoved.end(); ++iter)
+ while (mRefreshListState.RemovedIterator < mRefreshListState.Removed.end())
{
- const LLUUID cat_id = (*iter);
+ const LLUUID cat_id = (*mRefreshListState.RemovedIterator++);
updateRemovedCategory(cat_id);
+
+ curent_time = LLTimer::getTotalSeconds();
+ if (curent_time >= end_time)
+ return;
}
+ mRefreshListState.Removed.clear();
+ mRefreshListState.RemovedIterator = mRefreshListState.Removed.end();
// Get changed items from inventory model and update outfit tabs
// which might have been renamed.
@@ -888,9 +944,9 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id)
if (!cat)
{
LLInventoryObject* obj = gInventory.getObject(*items_iter);
- if(!obj || (obj->getType() != LLAssetType::AT_CATEGORY))
+ if (!obj || (obj->getType() != LLAssetType::AT_CATEGORY))
{
- return;
+ break;
}
cat = (LLViewerInventoryCategory*)obj;
}
@@ -900,6 +956,12 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id)
}
sortOutfits();
+ highlightBaseOutfit();
+
+ gIdleCallbacks.deleteFunction(onIdle, this);
+ mRefreshListState.CategoryUUID.setNull();
+
+ LL_INFOS() << "done" << LL_ENDL;
}
void LLOutfitListBase::computeDifference(
@@ -936,7 +998,6 @@ void LLOutfitListBase::highlightBaseOutfit()
mHighlightedOutfitUUID = base_id;
onHighlightBaseOutfit(base_id, prev_id);
}
-
}
void LLOutfitListBase::removeSelected()
diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h
index 66b3165169..7d212420a2 100644
--- a/indra/newview/lloutfitslist.h
+++ b/indra/newview/lloutfitslist.h
@@ -116,8 +116,20 @@ protected:
void onOutfitsRemovalConfirmation(const LLSD& notification, const LLSD& response);
virtual void onChangeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id) = 0;
+ static void onIdle(void* userdata);
+ void onIdleRefreshList();
+
+ struct
+ {
+ LLUUID CategoryUUID;
+ uuid_vec_t Added;
+ uuid_vec_t Removed;
+ uuid_vec_t::const_iterator AddedIterator;
+ uuid_vec_t::const_iterator RemovedIterator;
+ } mRefreshListState;
+
bool mIsInitialized;
- LLInventoryCategoriesObserver* mCategoriesObserver;
+ LLInventoryCategoriesObserver* mCategoriesObserver;
LLUUID mSelectedOutfitUUID;
// id of currently highlited outfit
LLUUID mHighlightedOutfitUUID;