Disposal safety

This commit is contained in:
Zeffuro
2026-01-02 23:42:12 +01:00
parent aec704dece
commit 7cec19f5f2
5 changed files with 32 additions and 23 deletions
@@ -217,7 +217,7 @@ public class InventoryLifecycles : IDisposable
Services.AddonLifecycle.UnregisterListener(AddonEvent.PreRefresh, ["Inventory", "InventoryLarge", "InventoryExpansion"]); Services.AddonLifecycle.UnregisterListener(AddonEvent.PreRefresh, ["Inventory", "InventoryLarge", "InventoryExpansion"]);
Services.AddonLifecycle.UnregisterListener(AddonEvent.PreRefresh, ["InventoryBuddy"]); 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, "Inventory", OnInventoryUpdate);
Services.AddonLifecycle.UnregisterListener(AddonEvent.PostRequestedUpdate, "InventoryBuddy", OnSaddleBagUpdate); Services.AddonLifecycle.UnregisterListener(AddonEvent.PostRequestedUpdate, "InventoryBuddy", OnSaddleBagUpdate);
+1 -2
View File
@@ -145,9 +145,8 @@ public abstract unsafe class InventoryAddonBase : NativeAddon, IInventoryWindow
if (SearchInputNode != null) if (SearchInputNode != null)
{ {
bool atActive = !string.IsNullOrEmpty(HighlightState.SelectedAllaganToolsFilterKey); 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) ? new Vector3(0.0f, 0.3f, 0.3f)
: Vector3.Zero; : Vector3.Zero;
} }
+20 -10
View File
@@ -1,8 +1,9 @@
using System; using System;
using AetherBags. Configuration; using AetherBags.Configuration;
using AetherBags. Inventory; using AetherBags.Inventory;
using AetherBags.Inventory.Context; using AetherBags.Inventory.Context;
using KamiToolKit.Classes. ContextMenu; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using KamiToolKit.Classes.ContextMenu;
namespace AetherBags.Addons; namespace AetherBags.Addons;
@@ -24,26 +25,26 @@ public static class InventoryAddonContextMenu
bool hasActiveAtFilter = !string.IsNullOrEmpty(HighlightState.SelectedAllaganToolsFilterKey); bool hasActiveAtFilter = !string.IsNullOrEmpty(HighlightState.SelectedAllaganToolsFilterKey);
string searchText = parent.GetSearchText(); string searchText = parent.GetSearchText();
if (HighlightState. IsFilterActive || hasActiveAtFilter || ! string.IsNullOrEmpty(searchText)) if (HighlightState.IsFilterActive || hasActiveAtFilter || !string.IsNullOrEmpty(searchText))
{ {
menu.AddItem("Clear All Filters", () => menu.AddItem("Clear All Filters", () =>
{ {
HighlightState.ClearAll(); HighlightState.ClearAll();
parent. SetSearchText(string.Empty); parent.SetSearchText(string.Empty);
InventoryOrchestrator.RefreshAll(updateMaps: false); InventoryOrchestrator.RefreshAll(updateMaps: false);
}); });
menu.AddItem(Separator); menu.AddItem(Separator);
} }
var currentMode = System. Config.General.SearchMode; var currentMode = System.Config.General.SearchMode;
string modeLabel = currentMode == SearchMode. Filter ? "Mode: Hide Non-Matches" : "Mode: Fade Non-Matches"; string modeLabel = currentMode == SearchMode.Filter ? "Mode: Hide Non-Matches" : "Mode: Fade Non-Matches";
menu.AddItem(modeLabel, () => 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(); 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(); var atFilters = System.IPC.AllaganTools.GetSearchFilters();
if (atFilters is { Count: > 0 }) if (atFilters is { Count: > 0 })
@@ -58,7 +59,7 @@ public static class InventoryAddonContextMenu
{ {
var capturedKey = key; var capturedKey = key;
bool isActive = HighlightState.SelectedAllaganToolsFilterKey == key; bool isActive = HighlightState.SelectedAllaganToolsFilterKey == key;
subMenu.AddItem(isActive ? $"✓ {name}" : $" {name}", () => subMenu.AddItem(isActive ?$"✓ {name}" : $" {name}", () =>
{ {
HighlightState.SelectedAllaganToolsFilterKey = isActive ? string.Empty : capturedKey; HighlightState.SelectedAllaganToolsFilterKey = isActive ? string.Empty : capturedKey;
InventoryOrchestrator.RefreshAll(updateMaps: false); InventoryOrchestrator.RefreshAll(updateMaps: false);
@@ -71,4 +72,13 @@ public static class InventoryAddonContextMenu
menu.Open(); menu.Open();
} }
public static unsafe void Close()
{
var agent = AgentContext.Instance();
if (agent != null)
{
agent->ClearMenu();
}
}
} }
+1
View File
@@ -14,5 +14,6 @@ public class IPCService : IDisposable
{ {
AllaganTools.Dispose(); AllaganTools.Dispose();
WotsIt.Dispose(); WotsIt.Dispose();
BisBuddy.Dispose();
} }
} }
+9 -10
View File
@@ -5,6 +5,7 @@ using AetherBags.Commands;
using AetherBags.Helpers; using AetherBags.Helpers;
using AetherBags.Hooks; using AetherBags.Hooks;
using AetherBags.Inventory; using AetherBags.Inventory;
using AetherBags.Inventory.Context;
using AetherBags.Inventory.State; using AetherBags.Inventory.State;
using AetherBags.IPC; using AetherBags.IPC;
using Dalamud.Game.Gui; using Dalamud.Game.Gui;
@@ -42,14 +43,14 @@ public unsafe class Plugin : IDalamudPlugin
System.AddonSaddleBagWindow = new AddonSaddleBagWindow System.AddonSaddleBagWindow = new AddonSaddleBagWindow
{ {
InternalName = "AetherBags_SaddleBag", InternalName = "AetherBags_SaddleBag",
Title = "AetherBags", Title = "AetherSaddlebag",
Size = new Vector2(750, 750), Size = new Vector2(750, 750),
}; };
System.AddonRetainerWindow = new AddonRetainerWindow System.AddonRetainerWindow = new AddonRetainerWindow
{ {
InternalName = "AetherBags_Retainer", InternalName = "AetherBags_Retainer",
Title = "AetherBags", Title = "AetherRetainerbag",
Size = new Vector2(750, 750), Size = new Vector2(750, 750),
}; };
@@ -78,22 +79,20 @@ public unsafe class Plugin : IDalamudPlugin
public void Dispose() public void Dispose()
{ {
System.IPC.Dispose(); InventoryAddonContextMenu.Close();
Util.SaveConfig(System.Config); _inventoryHooks.Dispose();
Services.ClientState.Login -= OnLogin; _inventoryLifecycles.Dispose();
Services.ClientState.Logout -= OnLogout;
_commandHandler.Dispose(); System.IPC.Dispose();
HighlightState.ClearAll();
System.AddonInventoryWindow.Dispose(); System.AddonInventoryWindow.Dispose();
System.AddonSaddleBagWindow.Dispose(); System.AddonSaddleBagWindow.Dispose();
System.AddonRetainerWindow.Dispose(); System.AddonRetainerWindow.Dispose();
System.AddonConfigurationWindow.Dispose(); System.AddonConfigurationWindow.Dispose();
Util.SaveConfig(System.Config);
KamiToolKitLibrary.Dispose(); KamiToolKitLibrary.Dispose();
_inventoryHooks.Dispose();
_inventoryLifecycles.Dispose();
} }
private void OnLogin() private void OnLogin()