From c0846c53d766cdd02d82c64747ba6a4f5ced51ba Mon Sep 17 00:00:00 2001 From: Hecklezz Date: Wed, 12 Aug 2026 03:30:06 +1000 Subject: [PATCH] [FIRE-36910] Fix crash when dragging onto the add button for custom inventory tabs --- indra/newview/fsinventorycustomtabs.cpp | 45 +++++++++++++++++++++++++ indra/newview/fsinventorycustomtabs.h | 3 ++ indra/newview/llpanelmaininventory.cpp | 6 ++++ 3 files changed, 54 insertions(+) diff --git a/indra/newview/fsinventorycustomtabs.cpp b/indra/newview/fsinventorycustomtabs.cpp index 17ada047f0..5e515593f1 100644 --- a/indra/newview/fsinventorycustomtabs.cpp +++ b/indra/newview/fsinventorycustomtabs.cpp @@ -219,6 +219,20 @@ bool FSInventoryCustomTabs::handleMouseDown(S32 x, S32 y) return true; } +bool FSInventoryCustomTabs::handleDragAndDrop(S32 x, S32 y) +{ + S32 local_x = 0; + S32 local_y = 0; + auto* inv_panel = hitTestAddTab(x, y, local_x, local_y); + if (!inv_panel) + { + return false; + } + // Drag and drop onto the Add button should not do anything + // Return true here to prevent calling LLPanel::handleDragAndDrop + return true; +} + void FSInventoryCustomTabs::onFilterFocusLost() { if (mParent) @@ -479,6 +493,12 @@ bool FSInventoryCustomTabs::handleMouseDown(LLPanelMainInventory* parent, S32 x, return self && self->handleMouseDown(x, y); } +bool FSInventoryCustomTabs::handleDragAndDrop(LLPanelMainInventory* parent, S32 x, S32 y) +{ + auto* self = instanceFor(parent); + return self && self->handleDragAndDrop(x, y); +} + void FSInventoryCustomTabs::onParentDraw(LLPanelMainInventory* parent) { if (auto* self = instanceFor(parent)) @@ -1232,6 +1252,31 @@ LLInventoryPanel* FSInventoryCustomTabs::hitTestCustomTab(S32 x, S32 y, S32& tab return inv_panel; } +LLInventoryPanel* FSInventoryCustomTabs::hitTestAddTab(S32 x, S32 y, S32& tab_local_x, S32& tab_local_y) const +{ + if (!mTabs || !mParent || !mAddTabPanel) + { + return nullptr; + } + tab_local_x = 0; + tab_local_y = 0; + if (!mParent->localPointToOtherView(x, y, &tab_local_x, &tab_local_y, mTabs)) + { + return nullptr; + } + const S32 idx = mTabs->getTabContainedAtPoint(tab_local_x, tab_local_y); + if (idx < 0) + { + return nullptr; + } + auto* inv_panel = dynamic_cast(mTabs->getPanelByIndex(idx)); + if (!isAddTab(inv_panel)) + { + return nullptr; + } + return inv_panel; +} + void FSInventoryCustomTabs::decorateCustomTabButton(LLInventoryPanel* panel) { if (!mTabs || !panel) diff --git a/indra/newview/fsinventorycustomtabs.h b/indra/newview/fsinventorycustomtabs.h index 5822b82ce3..331875d57f 100644 --- a/indra/newview/fsinventorycustomtabs.h +++ b/indra/newview/fsinventorycustomtabs.h @@ -52,6 +52,7 @@ public: bool handleRightMouseDown(S32 x, S32 y); bool handleMouseDown(S32 x, S32 y); + bool handleDragAndDrop(S32 x, S32 y); void noteActivePanel(LLInventoryPanel* panel); void notifyActiveFilterStateChanged(); @@ -81,6 +82,7 @@ public: static void notifyIfFilterChanged(LLPanelMainInventory* parent, S32 prev_generation); static bool handleRightMouseDown(LLPanelMainInventory* parent, S32 x, S32 y); static bool handleMouseDown(LLPanelMainInventory* parent, S32 x, S32 y); + static bool handleDragAndDrop(LLPanelMainInventory* parent, S32 x, S32 y); static void onParentDraw(LLPanelMainInventory* parent); private: @@ -112,6 +114,7 @@ private: void updateAutoLabel(LLInventoryPanel* panel); std::string computeDisplayLabel(LLInventoryPanel* panel) const; LLInventoryPanel* hitTestCustomTab(S32 x, S32 y, S32& tab_local_x, S32& tab_local_y) const; + LLInventoryPanel* hitTestAddTab(S32 x, S32 y, S32& tab_local_x, S32& tab_local_y) const; static std::string getDefaultTabName(); static std::string sanitizeTabName(std::string name); diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 5f37ecdb72..7aced76ff3 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -1371,6 +1371,12 @@ bool LLPanelMainInventory::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, } // [/SL:KB] + // [FIRE-36910] Fix crash when dragging onto the add button for custom inventory tabs + if (FSInventoryCustomTabs::handleDragAndDrop(this, x, y)) + { + return true; + } + // bool handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); return handled;