add support in isDescendantOf for breaking out of recursive parenting cases

This commit is contained in:
Hazim Gazov
2010-08-07 23:41:18 +00:00
parent 2f612dc1a2
commit 15b779fd00
2 changed files with 18 additions and 7 deletions

View File

@@ -205,18 +205,29 @@ LLInventoryModel::~LLInventoryModel()
// This is a convenience function to check if one object has a parent
// chain up to the category specified by UUID.
BOOL LLInventoryModel::isObjectDescendentOf(const LLUUID& obj_id,
const LLUUID& cat_id)
const LLUUID& cat_id,
const BOOL break_on_recursion)
{
LLInventoryObject* obj = getObject(obj_id);
int depthCounter = 0;
while(obj)
{
const LLUUID& parent_id = obj->getParentUUID();
// <edit>
if(parent_id == obj->getUUID())
if(break_on_recursion)
{
// infinite loop... same thing as having no parent, hopefully.
llwarns << "This shit has itself as parent! " << parent_id.asString() << ", " << obj->getName() << llendl;
return FALSE;
if(depthCounter++ >= 100)
{
llwarns << "In way too damn deep, possibly recursive parenting" << llendl;
llinfos << obj->getName() << " : " << obj->getUUID() << " : " << parent_id << llendl;
return FALSE;
}
if(parent_id == obj->getUUID())
{
// infinite loop... same thing as having no parent, hopefully.
llwarns << "This shit has itself as parent! " << parent_id.asString() << ", " << obj->getName() << llendl;
return FALSE;
}
}
// </edit>
if( parent_id.isNull() )
@@ -3489,7 +3500,7 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite
// <edit> I don't even think changing this did anything
//case LLAssetType::AT_CALLINGCARD:
// // not allowed
// break;
// break;
// </edit>
case LLAssetType::AT_OBJECT:

View File

@@ -130,7 +130,7 @@ public:
// This is a convenience function to check if one object has a
// parent chain up to the category specified by UUID.
BOOL isObjectDescendentOf(const LLUUID& obj_id, const LLUUID& cat_id);
BOOL isObjectDescendentOf(const LLUUID& obj_id, const LLUUID& cat_id, const BOOL break_on_recursion=FALSE);
// Get the object by id. Returns NULL if not found.
// * WARNING: use the pointer returned for read operations - do