summaryrefslogtreecommitdiff
path: root/indra/newview/llinventoryobserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventoryobserver.cpp')
-rw-r--r--indra/newview/llinventoryobserver.cpp48
1 files changed, 41 insertions, 7 deletions
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index bd6877d9d3..54b8f3a8a4 100644
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -676,7 +676,9 @@ void LLInventoryCategoriesObserver::changed(U32 mask)
iter != mCategoryMap.end();
++iter)
{
- LLViewerInventoryCategory* category = gInventory.getCategory((*iter).first);
+ const LLUUID& cat_id = (*iter).first;
+
+ LLViewerInventoryCategory* category = gInventory.getCategory(cat_id);
if (!category)
continue;
@@ -691,7 +693,7 @@ void LLInventoryCategoriesObserver::changed(U32 mask)
// Check number of known descendents to find out whether it has changed.
LLInventoryModel::cat_array_t* cats;
LLInventoryModel::item_array_t* items;
- gInventory.getDirectDescendentsOf((*iter).first, cats, items);
+ gInventory.getDirectDescendentsOf(cat_id, cats, items);
if (!cats || !items)
{
llwarns << "Category '" << category->getName() << "' descendents corrupted, fetch failed." << llendl;
@@ -703,20 +705,39 @@ void LLInventoryCategoriesObserver::changed(U32 mask)
continue;
}
-
+
const S32 current_num_known_descendents = cats->count() + items->count();
- LLCategoryData cat_data = (*iter).second;
+ LLCategoryData& cat_data = (*iter).second;
+
+ bool cat_changed = false;
// If category version or descendents count has changed
- // update category data in mCategoryMap and fire a callback.
+ // update category data in mCategoryMap
if (version != cat_data.mVersion || current_num_known_descendents != cat_data.mDescendentsCount)
{
cat_data.mVersion = version;
cat_data.mDescendentsCount = current_num_known_descendents;
+ cat_changed = true;
+ }
- cat_data.mCallback();
+ // If any item names have changed, update the name hash
+ // Only need to check if (a) name hash has not previously been
+ // computed, or (b) a name has changed.
+ if (!cat_data.mIsNameHashInitialized || (mask & LLInventoryObserver::LABEL))
+ {
+ LLMD5 item_name_hash = gInventory.hashDirectDescendentNames(cat_id);
+ if (cat_data.mItemNameHash != item_name_hash)
+ {
+ cat_data.mIsNameHashInitialized = true;
+ cat_data.mItemNameHash = item_name_hash;
+ cat_changed = true;
+ }
}
+
+ // If anything has changed above, fire the callback.
+ if (cat_changed)
+ cat_data.mCallback();
}
}
@@ -758,7 +779,8 @@ bool LLInventoryCategoriesObserver::addCategory(const LLUUID& cat_id, callback_t
if (can_be_added)
{
- mCategoryMap.insert(category_map_value_t(cat_id, LLCategoryData(cb, version, current_num_known_descendents)));
+ mCategoryMap.insert(category_map_value_t(
+ cat_id,LLCategoryData(cat_id, cb, version, current_num_known_descendents)));
}
return can_be_added;
@@ -768,3 +790,15 @@ void LLInventoryCategoriesObserver::removeCategory(const LLUUID& cat_id)
{
mCategoryMap.erase(cat_id);
}
+
+LLInventoryCategoriesObserver::LLCategoryData::LLCategoryData(
+ const LLUUID& cat_id, callback_t cb, S32 version, S32 num_descendents)
+
+ : mCatID(cat_id)
+ , mCallback(cb)
+ , mVersion(version)
+ , mDescendentsCount(num_descendents)
+ , mIsNameHashInitialized(false)
+{
+ mItemNameHash.finalize();
+}