Making AO less aggressive with purging folders and items. Fixes FIRE-5524

ziree 2012-03-29 16:50:17 +02:00
parent d876a9bdd8
commit 2177f87a1b
3 changed files with 95 additions and 0 deletions

View File

@ -716,6 +716,58 @@ BOOL AOEngine::addAnimation(const AOSet* set,AOSet::AOState* state,const LLInven
return TRUE;
}
BOOL AOEngine::findForeignItems(const LLUUID& uuid) const
{
BOOL moved=FALSE;
LLInventoryModel::item_array_t* items;
LLInventoryModel::cat_array_t* cats;
gInventory.getDirectDescendentsOf(uuid,cats,items);
for(S32 index=0;index<cats->count();index++)
{
// recurse into subfolders
if(findForeignItems(cats->get(index)->getUUID()))
{
moved=TRUE;
}
}
// count backwards in case we have to remove items
for(S32 index=items->count()-1;index>=0;index--)
{
BOOL move=FALSE;
LLPointer<LLViewerInventoryItem> item=items->get(index);
if(item->getIsLinkType())
{
if(item->getInventoryType()!=LLInventoryType::IT_ANIMATION)
{
lldebugs << item->getName() << " is a link but does not point to an animation." << llendl;
move=TRUE;
}
else
{
lldebugs << item->getName() << " is an animation link." << llendl;
}
}
else
{
lldebugs << item->getName() << " is not a link!" << llendl;
move=TRUE;
}
if(move)
{
moved=TRUE;
change_item_parent(&gInventory,item,gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND),FALSE);
lldebugs << item->getName() << " moved to lost and found!" << llendl;
}
}
return moved;
}
// needs a three-step process, since purge of categories only seems to work from trash
void AOEngine::purgeFolder(const LLUUID& uuid) const
{
@ -723,6 +775,12 @@ void AOEngine::purgeFolder(const LLUUID& uuid) const
BOOL wasProtected=gSavedPerAccountSettings.getBOOL("ProtectAOFolders");
gSavedPerAccountSettings.setBOOL("ProtectAOFolders",FALSE);
// move everything that's not an animation link to "lost and found"
if(findForeignItems(uuid))
{
LLNotificationsUtil::add("AOForeignItemsFound", LLSD());
}
// trash it
remove_category(&gInventory,uuid);
@ -752,6 +810,29 @@ BOOL AOEngine::removeAnimation(const AOSet* set,AOSet::AOState* state,S32 index)
if(numOfAnimations==0)
return FALSE;
LLViewerInventoryItem* item=gInventory.getItem(state->mAnimations[index].mInventoryUUID);
// check if this item is actually an animation link
BOOL move=TRUE;
if(item->getIsLinkType())
{
if(item->getInventoryType()==LLInventoryType::IT_ANIMATION)
{
// it is an animation link, so mark it to be purged
move=FALSE;
}
}
// this item was not an animation link, move it to lost and found
if(move)
{
change_item_parent(&gInventory,item,gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND),FALSE);
LLNotificationsUtil::add("AOForeignItemsFound", LLSD());
update();
return FALSE;
}
// purge the item from inventory
lldebugs << __LINE__ << " purging: " << state->mAnimations[index].mInventoryUUID << llendl;
gInventory.purgeObject(state->mAnimations[index].mInventoryUUID); // item->getUUID());
gInventory.notifyObservers();
@ -885,6 +966,12 @@ void AOEngine::update()
if(mAOFolder.isNull())
return;
// move everything that's not an animation link to "lost and found"
if(findForeignItems(mAOFolder))
{
LLNotificationsUtil::add("AOForeignItemsFound", LLSD());
}
LLInventoryModel::cat_array_t* categories;
LLInventoryModel::item_array_t* items;

View File

@ -168,6 +168,7 @@ class AOEngine
void saveState(const AOSet::AOState* state);
BOOL createAnimationLink(const AOSet* set,AOSet::AOState* state,const LLInventoryItem* item);
BOOL findForeignItems(const LLUUID& uuid) const;
void purgeFolder(const LLUUID& uuid) const;
void onToggleAOControl();

View File

@ -8284,6 +8284,13 @@ Remove AO set "[AO_SET_NAME]" from the list?
yestext="Remove"/>
</notification>
<notification
icon="notifytip.tga"
name="AOForeignItemsFound"
type="alertmodal">
The animation overrider found at least one item that did not belong in the configuration. Please check your &quot;Lost and Found&quot; folder for items that were moved out of the animation overrider configuration.
</notification>
<notification
icon="notifytip.tga"
name="AOImportSetAlreadyExists"