summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-06-10 02:28:48 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-06-10 02:28:48 +0300
commit14aa4dcdc23feafc537f06e49c48e9d693300103 (patch)
tree1c0af372af7a255e9e3fa62ac2637ddd429ddd47 /indra
parent417dbeb68ef842a8eee22ebab35c89ddee653619 (diff)
SL-19847 Delete key should not allow system folders
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llinventorygallery.cpp26
-rw-r--r--indra/newview/llinventorygallery.h1
2 files changed, 26 insertions, 1 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp
index 898bcba494..5edcb3148c 100644
--- a/indra/newview/llinventorygallery.cpp
+++ b/indra/newview/llinventorygallery.cpp
@@ -934,7 +934,7 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask)
#endif
// Delete selected items if delete or backspace key hit on the inventory panel
// Note: on Mac laptop keyboards, backspace and delete are one and the same
- if (mSelectedItemID.notNull())
+ if (canDeleteSelection())
{
deleteSelection();
}
@@ -1411,6 +1411,30 @@ void LLInventoryGallery::deleteSelection()
LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGallery::onDelete, _1, _2, mSelectedItemID));
}
+bool LLInventoryGallery::canDeleteSelection()
+{
+ if (mSelectedItemID.isNull())
+ {
+ return false;
+ }
+
+ LLViewerInventoryCategory* cat = gInventory.getCategory(mSelectedItemID);
+ if (cat)
+ {
+ if (!get_is_category_removable(&gInventory, mSelectedItemID))
+ {
+ return false;
+ }
+ }
+ else if (!get_is_item_removable(&gInventory, mSelectedItemID))
+ {
+ return false;
+ }
+
+ const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+ return !gInventory.isObjectDescendentOf(mSelectedItemID, trash_id);
+}
+
void LLInventoryGallery::pasteAsLink()
{
if (!LLClipboard::instance().hasContents())
diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h
index e71e2eddcd..6fbd1556e5 100644
--- a/indra/newview/llinventorygallery.h
+++ b/indra/newview/llinventorygallery.h
@@ -152,6 +152,7 @@ public:
// Copy & paste & delete
static void onDelete(const LLSD& notification, const LLSD& response, const LLUUID& selected_id);
void deleteSelection();
+ bool canDeleteSelection();
void pasteAsLink();
void claimEditHandler();