EXT-8360 FIX - item name changes get propagated to the various appearance panel widgets
parent
22232ccf05
commit
ca1224fd79
|
|
@ -294,6 +294,30 @@ void LLInventoryModel::getDirectDescendentsOf(const LLUUID& cat_id,
|
|||
items = get_ptr_in_map(mParentChildItemTree, cat_id);
|
||||
}
|
||||
|
||||
LLMD5 LLInventoryModel::hashDirectDescendentNames(const LLUUID& cat_id) const
|
||||
{
|
||||
LLInventoryModel::cat_array_t* cat_array;
|
||||
LLInventoryModel::item_array_t* item_array;
|
||||
getDirectDescendentsOf(cat_id,cat_array,item_array);
|
||||
LLMD5 item_name_hash;
|
||||
if (!item_array)
|
||||
{
|
||||
item_name_hash.finalize();
|
||||
return item_name_hash;
|
||||
}
|
||||
for (LLInventoryModel::item_array_t::const_iterator iter = item_array->begin();
|
||||
iter != item_array->end();
|
||||
iter++)
|
||||
{
|
||||
const LLViewerInventoryItem *item = (*iter);
|
||||
if (!item)
|
||||
continue;
|
||||
item_name_hash.update(item->getName());
|
||||
}
|
||||
item_name_hash.finalize();
|
||||
return item_name_hash;
|
||||
}
|
||||
|
||||
// SJB: Added version to lock the arrays to catch potential logic bugs
|
||||
void LLInventoryModel::lockDirectDescendentArrays(const LLUUID& cat_id,
|
||||
cat_array_t*& categories,
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include "lluuid.h"
|
||||
#include "llpermissionsflags.h"
|
||||
#include "llstring.h"
|
||||
#include "llmd5.h"
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
|
@ -194,6 +195,9 @@ public:
|
|||
void getDirectDescendentsOf(const LLUUID& cat_id,
|
||||
cat_array_t*& categories,
|
||||
item_array_t*& items) const;
|
||||
|
||||
// Compute a hash of direct descendent names (for detecting child name changes)
|
||||
LLMD5 hashDirectDescendentNames(const LLUUID& cat_id) const;
|
||||
|
||||
// Starting with the object specified, add its descendents to the
|
||||
// array provided, but do not add the inventory object specified
|
||||
|
|
|
|||
|
|
@ -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,33 @@ void LLInventoryCategoriesObserver::changed(U32 mask)
|
|||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
const S32 current_num_known_descendents = cats->count() + items->count();
|
||||
|
||||
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_data.mCallback();
|
||||
cat_changed = true;
|
||||
}
|
||||
|
||||
// If any item names have changed, update the name hash
|
||||
LLMD5 item_name_hash = gInventory.hashDirectDescendentNames(cat_id);
|
||||
if (cat_data.mItemNameHash != item_name_hash)
|
||||
{
|
||||
cat_data.mItemNameHash = item_name_hash;
|
||||
cat_changed = true;
|
||||
}
|
||||
|
||||
// If anything has changed above, fire the callback.
|
||||
if (cat_changed)
|
||||
cat_data.mCallback();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,12 +34,13 @@
|
|||
#define LL_LLINVENTORYOBSERVERS_H
|
||||
|
||||
#include "lluuid.h"
|
||||
#include "llmd5.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class LLViewerInventoryCategory;
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~v~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Class LLInventoryObserver
|
||||
//
|
||||
// A simple abstract base class that can relay messages when the inventory
|
||||
|
|
@ -298,11 +299,14 @@ protected:
|
|||
: mCallback(cb)
|
||||
, mVersion(version)
|
||||
, mDescendentsCount(num_descendents)
|
||||
{}
|
||||
{
|
||||
mItemNameHash.finalize();
|
||||
}
|
||||
|
||||
callback_t mCallback;
|
||||
S32 mVersion;
|
||||
S32 mDescendentsCount;
|
||||
LLMD5 mItemNameHash;
|
||||
};
|
||||
|
||||
typedef std::map<LLUUID, LLCategoryData> category_map_t;
|
||||
|
|
|
|||
|
|
@ -89,12 +89,11 @@ bool LLOutfitObserver::checkCOF()
|
|||
return false;
|
||||
|
||||
bool cof_changed = false;
|
||||
LLMD5 itemNameHash;
|
||||
hashItemNames(itemNameHash);
|
||||
if (itemNameHash != mItemNameHash)
|
||||
LLMD5 item_name_hash = gInventory.hashDirectDescendentNames(cof);
|
||||
if (item_name_hash != mItemNameHash)
|
||||
{
|
||||
cof_changed = true;
|
||||
mItemNameHash = itemNameHash;
|
||||
mItemNameHash = item_name_hash;
|
||||
}
|
||||
|
||||
S32 cof_version = getCategoryVersion(cof);
|
||||
|
|
@ -114,27 +113,6 @@ bool LLOutfitObserver::checkCOF()
|
|||
return true;
|
||||
}
|
||||
|
||||
void LLOutfitObserver::hashItemNames(LLMD5& itemNameHash)
|
||||
{
|
||||
LLInventoryModel::cat_array_t cat_array;
|
||||
LLInventoryModel::item_array_t item_array;
|
||||
gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(),
|
||||
cat_array,
|
||||
item_array,
|
||||
false);
|
||||
for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin();
|
||||
iter != item_array.end();
|
||||
iter++)
|
||||
{
|
||||
const LLViewerInventoryItem *item = (*iter);
|
||||
if (!item)
|
||||
continue;
|
||||
const std::string& name = item->getName();
|
||||
itemNameHash.update(name);
|
||||
}
|
||||
itemNameHash.finalize();
|
||||
}
|
||||
|
||||
void LLOutfitObserver::checkBaseOutfit()
|
||||
{
|
||||
LLUUID baseoutfit_id =
|
||||
|
|
|
|||
|
|
@ -73,8 +73,6 @@ protected:
|
|||
|
||||
bool checkCOF();
|
||||
|
||||
void hashItemNames(LLMD5& itemNameHash);
|
||||
|
||||
void checkBaseOutfit();
|
||||
|
||||
//last version number of a COF category
|
||||
|
|
|
|||
Loading…
Reference in New Issue