From 7cec19f5f21d593a05a0d98f163be0104a9ac0f3 Mon Sep 17 00:00:00 2001 From: Zeffuro Date: Fri, 2 Jan 2026 23:42:12 +0100 Subject: [PATCH] Disposal safety --- .../AddonLifecycles/InventoryLifecycles.cs | 2 +- AetherBags/Addons/InventoryAddonBase.cs | 3 +- .../Addons/InventoryAddonContextMenu.cs | 30 ++++++++++++------- AetherBags/IPC/IPCService.cs | 1 + AetherBags/Plugin.cs | 19 ++++++------ 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/AetherBags/AddonLifecycles/InventoryLifecycles.cs b/AetherBags/AddonLifecycles/InventoryLifecycles.cs index ed1e38f..d35639b 100644 --- a/AetherBags/AddonLifecycles/InventoryLifecycles.cs +++ b/AetherBags/AddonLifecycles/InventoryLifecycles.cs @@ -217,7 +217,7 @@ public class InventoryLifecycles : IDisposable Services.AddonLifecycle.UnregisterListener(AddonEvent.PreRefresh, ["Inventory", "InventoryLarge", "InventoryExpansion"]); Services.AddonLifecycle.UnregisterListener(AddonEvent.PreRefresh, ["InventoryBuddy"]); - Services.AddonLifecycle.UnregisterListener(AddonEvent.PreRefresh, ["InventoryRetainer, InventoryRetainerLarge"]); + Services.AddonLifecycle.UnregisterListener(AddonEvent.PreRefresh, ["InventoryRetainer", "InventoryRetainerLarge"]); Services.AddonLifecycle.UnregisterListener(AddonEvent.PostRequestedUpdate, "Inventory", OnInventoryUpdate); Services.AddonLifecycle.UnregisterListener(AddonEvent.PostRequestedUpdate, "InventoryBuddy", OnSaddleBagUpdate); diff --git a/AetherBags/Addons/InventoryAddonBase.cs b/AetherBags/Addons/InventoryAddonBase.cs index 843e176..678c52b 100644 --- a/AetherBags/Addons/InventoryAddonBase.cs +++ b/AetherBags/Addons/InventoryAddonBase.cs @@ -145,9 +145,8 @@ public abstract unsafe class InventoryAddonBase : NativeAddon, IInventoryWindow if (SearchInputNode != null) { bool atActive = !string.IsNullOrEmpty(HighlightState.SelectedAllaganToolsFilterKey); - bool filterModeActive = System.Config.General.SearchMode == SearchMode.Filter; - SearchInputNode.HintAddColor = (atActive || filterModeActive) + SearchInputNode.HintAddColor = (atActive) ? new Vector3(0.0f, 0.3f, 0.3f) : Vector3.Zero; } diff --git a/AetherBags/Addons/InventoryAddonContextMenu.cs b/AetherBags/Addons/InventoryAddonContextMenu.cs index 60bb32d..cee746a 100644 --- a/AetherBags/Addons/InventoryAddonContextMenu.cs +++ b/AetherBags/Addons/InventoryAddonContextMenu.cs @@ -1,8 +1,9 @@ using System; -using AetherBags. Configuration; -using AetherBags. Inventory; +using AetherBags.Configuration; +using AetherBags.Inventory; using AetherBags.Inventory.Context; -using KamiToolKit.Classes. ContextMenu; +using FFXIVClientStructs.FFXIV.Client.UI.Agent; +using KamiToolKit.Classes.ContextMenu; namespace AetherBags.Addons; @@ -24,26 +25,26 @@ public static class InventoryAddonContextMenu bool hasActiveAtFilter = !string.IsNullOrEmpty(HighlightState.SelectedAllaganToolsFilterKey); string searchText = parent.GetSearchText(); - if (HighlightState. IsFilterActive || hasActiveAtFilter || ! string.IsNullOrEmpty(searchText)) + if (HighlightState.IsFilterActive || hasActiveAtFilter || !string.IsNullOrEmpty(searchText)) { menu.AddItem("Clear All Filters", () => { HighlightState.ClearAll(); - parent. SetSearchText(string.Empty); + parent.SetSearchText(string.Empty); InventoryOrchestrator.RefreshAll(updateMaps: false); }); menu.AddItem(Separator); } - var currentMode = System. Config.General.SearchMode; - string modeLabel = currentMode == SearchMode. Filter ? "Mode: Hide Non-Matches" : "Mode: Fade Non-Matches"; + var currentMode = System.Config.General.SearchMode; + string modeLabel = currentMode == SearchMode.Filter ? "Mode: Hide Non-Matches" : "Mode: Fade Non-Matches"; menu.AddItem(modeLabel, () => { - System.Config.General.SearchMode = currentMode == SearchMode. Filter ? SearchMode. Highlight : SearchMode.Filter; + System.Config.General.SearchMode = currentMode == SearchMode.Filter ? SearchMode.Highlight : SearchMode.Filter; parent.ManualRefresh(); }); - if (System.IPC.AllaganTools is { IsReady: true } && System. Config.Categories.AllaganToolsCategoriesEnabled) + if (System.IPC.AllaganTools is { IsReady: true } && System.Config.Categories.AllaganToolsCategoriesEnabled) { var atFilters = System.IPC.AllaganTools.GetSearchFilters(); if (atFilters is { Count: > 0 }) @@ -58,7 +59,7 @@ public static class InventoryAddonContextMenu { var capturedKey = key; bool isActive = HighlightState.SelectedAllaganToolsFilterKey == key; - subMenu.AddItem(isActive ? $"✓ {name}" : $" {name}", () => + subMenu.AddItem(isActive ?$"✓ {name}" : $" {name}", () => { HighlightState.SelectedAllaganToolsFilterKey = isActive ? string.Empty : capturedKey; InventoryOrchestrator.RefreshAll(updateMaps: false); @@ -71,4 +72,13 @@ public static class InventoryAddonContextMenu menu.Open(); } + + public static unsafe void Close() + { + var agent = AgentContext.Instance(); + if (agent != null) + { + agent->ClearMenu(); + } + } } \ No newline at end of file diff --git a/AetherBags/IPC/IPCService.cs b/AetherBags/IPC/IPCService.cs index 73d2a5e..38bc733 100644 --- a/AetherBags/IPC/IPCService.cs +++ b/AetherBags/IPC/IPCService.cs @@ -14,5 +14,6 @@ public class IPCService : IDisposable { AllaganTools.Dispose(); WotsIt.Dispose(); + BisBuddy.Dispose(); } } \ No newline at end of file diff --git a/AetherBags/Plugin.cs b/AetherBags/Plugin.cs index 7b4e031..5199378 100644 --- a/AetherBags/Plugin.cs +++ b/AetherBags/Plugin.cs @@ -5,6 +5,7 @@ using AetherBags.Commands; using AetherBags.Helpers; using AetherBags.Hooks; using AetherBags.Inventory; +using AetherBags.Inventory.Context; using AetherBags.Inventory.State; using AetherBags.IPC; using Dalamud.Game.Gui; @@ -42,14 +43,14 @@ public unsafe class Plugin : IDalamudPlugin System.AddonSaddleBagWindow = new AddonSaddleBagWindow { InternalName = "AetherBags_SaddleBag", - Title = "AetherBags", + Title = "AetherSaddlebag", Size = new Vector2(750, 750), }; System.AddonRetainerWindow = new AddonRetainerWindow { InternalName = "AetherBags_Retainer", - Title = "AetherBags", + Title = "AetherRetainerbag", Size = new Vector2(750, 750), }; @@ -78,22 +79,20 @@ public unsafe class Plugin : IDalamudPlugin public void Dispose() { - System.IPC.Dispose(); - Util.SaveConfig(System.Config); - Services.ClientState.Login -= OnLogin; - Services.ClientState.Logout -= OnLogout; + InventoryAddonContextMenu.Close(); + _inventoryHooks.Dispose(); + _inventoryLifecycles.Dispose(); - _commandHandler.Dispose(); + System.IPC.Dispose(); + HighlightState.ClearAll(); System.AddonInventoryWindow.Dispose(); System.AddonSaddleBagWindow.Dispose(); System.AddonRetainerWindow.Dispose(); System.AddonConfigurationWindow.Dispose(); + Util.SaveConfig(System.Config); KamiToolKitLibrary.Dispose(); - - _inventoryHooks.Dispose(); - _inventoryLifecycles.Dispose(); } private void OnLogin()