From d237b9ee1b0bbcdb3431f8afc873af4ee9e21a4e Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 21 Jul 2023 17:19:04 +0300
Subject: [PATCH] SL-20040 Fix selection callback

---
 indra/newview/llinventorygallery.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp
index 99bd772773f..87dba5f100a 100644
--- a/indra/newview/llinventorygallery.cpp
+++ b/indra/newview/llinventorygallery.cpp
@@ -1302,7 +1302,7 @@ void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLU
         if (std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id) == mSelectedItemIDs.end())
         {
             mSelectedItemIDs.clear();
-            mSelectedItemIDs.push_back(item_id);
+            changeItemSelection(item_id, false);
         }
         uuid_vec_t selected_uuids;
         selected_uuids.push_back(item_id);
@@ -1318,8 +1318,10 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_
         mNeedsSelection = true;
         return;
     }
-    if (std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id) == mSelectedItemIDs.end())
+    if (mSelectedItemIDs.size() == 1
+        && std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id) != mSelectedItemIDs.end())
     {
+        // Already selected
         return;
     }
 
@@ -1330,6 +1332,7 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_
             mItemMap[id]->setSelected(FALSE);
         }
     }
+    mSelectedItemIDs.clear();
 
     if (mItemMap[item_id])
     {
@@ -2388,9 +2391,6 @@ BOOL LLInventoryGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask)
 {
     setFocus(TRUE);
     mGallery->claimEditHandler();
-
-    //S32 gal_x, gal_y;
-    //localPointToOtherView(x, y, &gal_x, &gal_y, mGallery);
     mGallery->showContextMenu(this, x, y, mUUID);
 
     LLUICtrl::handleRightMouseDown(x, y, mask);
-- 
GitLab