MAINT-7424 Fixed number of items in the Trash not calculating correctly

meow-7.2.2
andreykproductengine 2017-05-19 18:47:20 +03:00
parent c31ef2a4b2
commit 8f17db9563
3 changed files with 22 additions and 23 deletions

View File

@ -894,22 +894,6 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id,
// [/RLVa:KB]
}
U32 LLInventoryModel::getDescendentsCountRecursive(const LLUUID& id, U32 max_item_limit)
{
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
gInventory.collectDescendents(id, cats, items, LLInventoryModel::INCLUDE_TRASH);
U32 items_found = items.size() + cats.size();
for (U32 i = 0; i < cats.size() && items_found <= max_item_limit; ++i)
{
items_found += getDescendentsCountRecursive(cats[i]->getUUID(), max_item_limit - items_found);
}
return items_found;
}
void LLInventoryModel::addChangedMaskForLinks(const LLUUID& object_id, U32 mask)
{
const LLInventoryObject *obj = getObject(object_id);
@ -3507,9 +3491,12 @@ void LLInventoryModel::emptyFolderType(const std::string notification, LLFolderT
LLSD args;
if(LLFolderType::FT_TRASH == preferred_type)
{
static const U32 trash_max_capacity = gSavedSettings.getU32("InventoryTrashMaxCapacity");
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
const LLUUID trash_id = findCategoryUUIDForType(preferred_type);
args["COUNT"] = (S32)getDescendentsCountRecursive(trash_id, trash_max_capacity);
gInventory.collectDescendents(trash_id, cats, items, LLInventoryModel::INCLUDE_TRASH); //All descendants
S32 item_count = items.size() + cats.size();
args["COUNT"] = item_count;
}
LLNotificationsUtil::add(notification, args, LLSD(),
boost::bind(&LLInventoryModel::callbackEmptyFolderType, this, _1, _2, preferred_type));
@ -3619,9 +3606,20 @@ bool callback_preview_trash_folder(const LLSD& notification, const LLSD& respons
void LLInventoryModel::checkTrashOverflow()
{
static const U32 trash_max_capacity = gSavedSettings.getU32("InventoryTrashMaxCapacity");
static LLCachedControl<U32> trash_max_capacity(gSavedSettings, "InventoryTrashMaxCapacity");
// Collect all descendants including those in subfolders.
//
// Note: Do we really need content of subfolders?
// This was made to prevent download of trash folder timeouting
// viewer and sub-folders are supposed to download independently.
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
const LLUUID trash_id = findCategoryUUIDForType(LLFolderType::FT_TRASH);
if (getDescendentsCountRecursive(trash_id, trash_max_capacity) >= trash_max_capacity)
gInventory.collectDescendents(trash_id, cats, items, LLInventoryModel::INCLUDE_TRASH);
S32 item_count = items.size() + cats.size();
if (item_count >= trash_max_capacity)
{
if (LLFloaterPreviewTrash::isVisible())
{

View File

@ -290,8 +290,6 @@ public:
const LLUUID& start_folder_id = LLUUID::null);
// </FS:Ansariel>
U32 getDescendentsCountRecursive(const LLUUID& id, U32 max_item_limit);
//--------------------------------------------------------------------
// Find
//--------------------------------------------------------------------

View File

@ -1354,7 +1354,10 @@ void LLInventoryPanel::purgeSelectedItems()
++it)
{
LLUUID item_id = static_cast<LLFolderViewModelItemInventory*>((*it)->getViewModelItem())->getUUID();
count += gInventory.getDescendentsCountRecursive(item_id, trash_max_capacity);
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
gInventory.collectDescendents(item_id, cats, items, LLInventoryModel::INCLUDE_TRASH);
count += items.size() + cats.size();
}
args["COUNT"] = count;
LLNotificationsUtil::add("PurgeSelectedItems", args, LLSD(), boost::bind(&LLInventoryPanel::callbackPurgeSelectedItems, this, _1, _2));