[FIRE-36910] Fix crash when dragging onto the add button for custom inventory tabs

This commit is contained in:
Hecklezz
2026-08-12 03:31:31 +10:00
parent 08e2450baf
commit c0846c53d7
3 changed files with 54 additions and 0 deletions
+45
View File
@@ -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<LLInventoryPanel*>(mTabs->getPanelByIndex(idx));
if (!isAddTab(inv_panel))
{
return nullptr;
}
return inv_panel;
}
void FSInventoryCustomTabs::decorateCustomTabButton(LLInventoryPanel* panel)
{
if (!mTabs || !panel)
+3
View File
@@ -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);
+6
View File
@@ -1371,6 +1371,12 @@ bool LLPanelMainInventory::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
}
// [/SL:KB]
// <FS:TJ> [FIRE-36910] Fix crash when dragging onto the add button for custom inventory tabs
if (FSInventoryCustomTabs::handleDragAndDrop(this, x, y))
{
return true;
}
// </FS:TJ>
bool handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
return handled;