From e4d6ea8b7485ed0dfb84e6e72e0d754679836a41 Mon Sep 17 00:00:00 2001 From: Arufonsu <17498701+Arufonsu@users.noreply.github.com> Date: Sun, 1 Feb 2026 21:02:08 -0300 Subject: [PATCH 1/2] fix: OnContextMenuOpening crash with empty bag and bank slots Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com> --- Intersect.Client.Core/Interface/Game/Bag/BagItem.cs | 10 ++++++---- .../Interface/Game/Bank/BankItem.cs | 13 +++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs index c2c83e97a1..5aa6037017 100644 --- a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs @@ -56,18 +56,20 @@ public BagItem(BagWindow bagWindow, Base parent, int index, ContextMenu contextM protected override void OnContextMenuOpening(ContextMenu contextMenu) { - if (Globals.BagSlots is not { Length: > 0 } bagSlots) + // Clear out the old options since we might not show all of them + contextMenu.ClearChildren(); + + if (Globals.BagSlots[SlotIndex] is not { } bagSlot) { return; } - if (!ItemDescriptor.TryGet(bagSlots[SlotIndex].ItemId, out var item)) + if (!ItemDescriptor.TryGet(bagSlot.ItemId, out var item)) { return; } - // Clear the context menu and add the withdraw item with updated item name - contextMenu.ClearChildren(); + // update context menu _withdrawContextItem.SetText(Strings.BagContextMenu.Withdraw.ToString(item.Name)); contextMenu.AddChild(_withdrawContextItem); base.OnContextMenuOpening(contextMenu); diff --git a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs index a9c7194737..371fd7b608 100644 --- a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs @@ -59,21 +59,22 @@ public BankItem(BankWindow bankWindow, Base parent, int index, ContextMenu conte protected override void OnContextMenuOpening(ContextMenu contextMenu) { - if (Globals.BankSlots is not { Length: > 0 } bankSlots) + // Clear out the old options since we might not show all of them + contextMenu.ClearChildren(); + + if (Globals.BankSlots[SlotIndex] is not { } bankSlot) { return; } - if (!ItemDescriptor.TryGet(bankSlots[SlotIndex].ItemId, out var item)) + if (!ItemDescriptor.TryGet(bankSlot.ItemId, out var item)) { return; } - // Clear the context menu and add the withdraw item with updated item name - contextMenu.ClearChildren(); - contextMenu.AddChild(_withdrawContextItem); + // update context menu _withdrawContextItem.SetText(Strings.BankContextMenu.Withdraw.ToString(item.Name)); - + contextMenu.AddChild(_withdrawContextItem); base.OnContextMenuOpening(contextMenu); } From 4c397686029b075cbb3f1b451471806d8abc4528 Mon Sep 17 00:00:00 2001 From: Arufonsu <17498701+Arufonsu@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:16:13 -0300 Subject: [PATCH 2/2] panda's review Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com> --- .../Interface/Game/Bag/BagItem.cs | 16 ++++++++++++---- .../Interface/Game/Bank/BankItem.cs | 19 ++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs index 5aa6037017..3f8c939d3b 100644 --- a/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bag/BagItem.cs @@ -56,20 +56,28 @@ public BagItem(BagWindow bagWindow, Base parent, int index, ContextMenu contextM protected override void OnContextMenuOpening(ContextMenu contextMenu) { - // Clear out the old options since we might not show all of them contextMenu.ClearChildren(); - if (Globals.BagSlots[SlotIndex] is not { } bagSlot) + if (Globals.BagSlots is not { Length: > 0 } bagSlots) + { + return; + } + + if (bagSlots[SlotIndex] is null) + { + return; + } + + if (SlotIndex >= bagSlots.Length) { return; } - if (!ItemDescriptor.TryGet(bagSlot.ItemId, out var item)) + if (!ItemDescriptor.TryGet(bagSlots[SlotIndex].ItemId, out var item)) { return; } - // update context menu _withdrawContextItem.SetText(Strings.BagContextMenu.Withdraw.ToString(item.Name)); contextMenu.AddChild(_withdrawContextItem); base.OnContextMenuOpening(contextMenu); diff --git a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs index 371fd7b608..753fd07b9e 100644 --- a/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs +++ b/Intersect.Client.Core/Interface/Game/Bank/BankItem.cs @@ -59,20 +59,29 @@ public BankItem(BankWindow bankWindow, Base parent, int index, ContextMenu conte protected override void OnContextMenuOpening(ContextMenu contextMenu) { - // Clear out the old options since we might not show all of them - contextMenu.ClearChildren(); + contextMenu.ClearChildren(); // Clear context menu + + if (Globals.BankSlots is not { Length: > 0 } bankSlots) + { + return; + } + + if (bankSlots[SlotIndex] is null) + { + return; + } - if (Globals.BankSlots[SlotIndex] is not { } bankSlot) + if (SlotIndex >= bankSlots.Length) { return; } - if (!ItemDescriptor.TryGet(bankSlot.ItemId, out var item)) + if (!ItemDescriptor.TryGet(bankSlots[SlotIndex].ItemId, out var item)) { return; } - // update context menu + // Update context menu _withdrawContextItem.SetText(Strings.BankContextMenu.Withdraw.ToString(item.Name)); contextMenu.AddChild(_withdrawContextItem); base.OnContextMenuOpening(contextMenu);