summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorygallerymenu.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-10-16 22:32:22 +0300
committerakleshchev <117672381+akleshchev@users.noreply.github.com>2023-10-17 21:26:39 +0300
commit13ab6a408b1f42de278edf8a2517b9ed3dc6c66d (patch)
tree47a0775022457a20d9454148b34397c2fd03868d /indra/newview/llinventorygallerymenu.cpp
parent813b0e7675f0f9fb682831bdf60319f8b584b882 (diff)
SL-20232 Fix gallery not checking descendants
Diffstat (limited to 'indra/newview/llinventorygallerymenu.cpp')
-rw-r--r--indra/newview/llinventorygallerymenu.cpp44
1 files changed, 41 insertions, 3 deletions
diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp
index d4cf9c2f9f..49969e1a52 100644
--- a/indra/newview/llinventorygallerymenu.cpp
+++ b/indra/newview/llinventorygallerymenu.cpp
@@ -388,6 +388,44 @@ bool is_inbox_folder(LLUUID item_id)
return gInventory.isObjectDescendentOf(item_id, inbox_id);
}
+bool is_category_removable(const LLUUID &folder_id, bool check_worn)
+{
+ if (!get_is_category_removable(&gInventory, folder_id))
+ {
+ return false;
+ }
+
+ // check children
+ LLInventoryModel::cat_array_t* cat_array;
+ LLInventoryModel::item_array_t* item_array;
+ gInventory.getDirectDescendentsOf(folder_id, cat_array, item_array);
+
+ for (LLInventoryModel::item_array_t::value_type& item : *item_array)
+ {
+ if (!get_is_item_removable(&gInventory, item->getUUID(), check_worn))
+ {
+ return false;
+ }
+ }
+
+ for (LLInventoryModel::cat_array_t::value_type& cat : *cat_array)
+ {
+ if (!is_category_removable(cat->getUUID(), check_worn))
+ {
+ return false;
+ }
+ }
+
+ const LLUUID mp_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS);
+ if (mp_id.notNull() && gInventory.isObjectDescendentOf(folder_id, mp_id))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+
void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* menu)
{
LLUUID selected_id = mUUIDs.front();
@@ -495,7 +533,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men
}
}
items.push_back(std::string("Purge Item"));
- if (is_folder && !get_is_category_removable(&gInventory, selected_id))
+ if (is_folder && !is_category_removable(selected_id, true))
{
disabled_items.push_back(std::string("Purge Item"));
}
@@ -542,8 +580,8 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men
}
items.push_back(std::string("Cut"));
items.push_back(std::string("Delete"));
- // TODO: check descendants!!!
- if(!get_is_category_removable(&gInventory, selected_id))
+
+ if(!is_category_removable(selected_id, true))
{
disabled_items.push_back(std::string("Delete"));
disabled_items.push_back(std::string("Cut"));