SL-20011 Restrict 'Empty Trash' if objects are attached

master
Maxim Nikolenko 2023-07-15 14:23:44 +03:00 committed by GitHub
parent 8b89a72195
commit d573bc2f92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View File

@ -4141,7 +4141,8 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items
|| is_recent_panel
|| !trash
|| trash->getVersion() == LLViewerInventoryCategory::VERSION_UNKNOWN
|| trash->getDescendentCount() == LLViewerInventoryCategory::VERSION_UNKNOWN)
|| trash->getDescendentCount() == LLViewerInventoryCategory::VERSION_UNKNOWN
|| gAgentAvatarp->hasAttachmentsInTrash())
{
disabled_items.push_back(std::string("Empty Trash"));
}

View File

@ -1247,6 +1247,27 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
return FALSE;
}
bool LLVOAvatarSelf::hasAttachmentsInTrash()
{
const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ++iter)
{
LLViewerJointAttachment *attachment = iter->second;
for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
attachment_iter != attachment->mAttachedObjects.end();
++attachment_iter)
{
LLViewerObject *attached_object = attachment_iter->get();
if (attached_object && gInventory.isObjectDescendentOf(attached_object->getAttachmentItemID(), trash_id))
{
return true;
}
}
}
return false;
}
// static
BOOL LLVOAvatarSelf::detachAttachmentIntoInventory(const LLUUID &item_id)
{

View File

@ -289,6 +289,8 @@ public:
/*virtual*/ BOOL detachObject(LLViewerObject *viewer_object);
static BOOL detachAttachmentIntoInventory(const LLUUID& item_id);
bool hasAttachmentsInTrash();
//--------------------------------------------------------------------
// HUDs
//--------------------------------------------------------------------