From fb7be87bebd785a7a3e7a7b59103bc952d98dc83 Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Mon, 8 May 2017 18:05:10 +0300
Subject: [PATCH] MAINT-7354 correction to misbehaving 'purge' and notification
 spam.

---
 indra/newview/llfloaterpreviewtrash.cpp |  8 +++++++-
 indra/newview/llfloaterpreviewtrash.h   |  1 +
 indra/newview/llinventorymodel.cpp      | 12 ++++++++++--
 indra/newview/llinventorypanel.cpp      | 16 ++++++++++++++++
 indra/newview/llinventorypanel.h        |  1 +
 5 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llfloaterpreviewtrash.cpp b/indra/newview/llfloaterpreviewtrash.cpp
index 084e914c9eb..717d0ddcad5 100644
--- a/indra/newview/llfloaterpreviewtrash.cpp
+++ b/indra/newview/llfloaterpreviewtrash.cpp
@@ -60,7 +60,13 @@ LLFloaterPreviewTrash::~LLFloaterPreviewTrash()
 // static
 void LLFloaterPreviewTrash::show()
 {
-	LLFloaterReg::showTypedInstance<LLFloaterPreviewTrash>("preview_trash");
+	LLFloaterReg::showTypedInstance<LLFloaterPreviewTrash>("preview_trash", LLSD(), TRUE);
+}
+
+// static
+bool LLFloaterPreviewTrash::isVisible()
+{
+	return LLFloaterReg::instanceVisible("preview_trash");
 }
 
 
diff --git a/indra/newview/llfloaterpreviewtrash.h b/indra/newview/llfloaterpreviewtrash.h
index 6fc0fe69283..465c0c677fc 100644
--- a/indra/newview/llfloaterpreviewtrash.h
+++ b/indra/newview/llfloaterpreviewtrash.h
@@ -35,6 +35,7 @@ class LLFloaterPreviewTrash
 {
 public:
 	static void show();
+	static bool isVisible();
 
 	LLFloaterPreviewTrash(const LLSD& key);
 	~LLFloaterPreviewTrash();
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 0fe03583f5b..e5fd126d53c 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -3437,8 +3437,16 @@ void  LLInventoryModel::checkTrashOverflow()
 	const LLUUID trash_id = findCategoryUUIDForType(LLFolderType::FT_TRASH);
 	if (getDescendentsCountRecursive(trash_id, trash_max_capacity) >= trash_max_capacity)
 	{
-		LLNotificationsUtil::add("TrashIsFull", LLSD(), LLSD(),
-			boost::bind(callback_preview_trash_folder, _1, _2));
+		if (LLFloaterPreviewTrash::isVisible())
+		{
+			// bring to front
+			LLFloaterPreviewTrash::show();
+		}
+		else
+		{
+			LLNotificationsUtil::add("TrashIsFull", LLSD(), LLSD(),
+				boost::bind(callback_preview_trash_folder, _1, _2));
+		}
 	}
 }
 
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 9de0633edb2..a00dcf02abb 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -168,6 +168,7 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) :
 	mCommitCallbackRegistrar.add("Inventory.BeginIMSession", boost::bind(&LLInventoryPanel::beginIMSession, this));
 	mCommitCallbackRegistrar.add("Inventory.Share",  boost::bind(&LLAvatarActions::shareWithAvatars, this));
 	mCommitCallbackRegistrar.add("Inventory.FileUploadLocation", boost::bind(&LLInventoryPanel::fileUploadLocation, this, _2));
+	mCommitCallbackRegistrar.add("Inventory.Purge", boost::bind(&LLInventoryPanel::purgeSelectedItems, this));
 }
 
 LLFolderView * LLInventoryPanel::createFolderRoot(LLUUID root_id )
@@ -1211,6 +1212,21 @@ void LLInventoryPanel::fileUploadLocation(const LLSD& userdata)
     }
 }
 
+void LLInventoryPanel::purgeSelectedItems()
+{
+    const std::set<LLFolderViewItem*> inventory_selected = mFolderRoot.get()->getSelectionList();
+    if (inventory_selected.empty()) return;
+
+    std::set<LLFolderViewItem*>::const_iterator it = inventory_selected.begin();
+    const std::set<LLFolderViewItem*>::const_iterator it_end = inventory_selected.end();
+    for (; it != it_end; ++it)
+    {
+        LLUUID item_id = static_cast<LLFolderViewModelItemInventory*>((*it)->getViewModelItem())->getUUID();
+        remove_inventory_object(item_id, NULL);
+    }
+}
+
+
 bool LLInventoryPanel::attachObject(const LLSD& userdata)
 {
 	// Copy selected item UUIDs to a vector.
diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h
index 5cb9dde47a8..7f63ea97ccb 100644
--- a/indra/newview/llinventorypanel.h
+++ b/indra/newview/llinventorypanel.h
@@ -202,6 +202,7 @@ class LLInventoryPanel : public LLPanel
 	void doCreate(const LLSD& userdata);
 	bool beginIMSession();
 	void fileUploadLocation(const LLSD& userdata);
+	void purgeSelectedItems();
 	bool attachObject(const LLSD& userdata);
 	static void idle(void* user_data);
 
-- 
GitLab