fix: Attempt to better handle hook disposal (#1803)

- Use a Weak Concurrent Collection to track scoped hooks
- Make `Hook`s remove themselves from the Tracked Hook list.
This commit is contained in:
KazWolfe 2025-03-13 14:16:28 -07:00 committed by goaaats
parent 203d80c602
commit a2124bb73d
8 changed files with 67 additions and 21 deletions

View file

@ -258,8 +258,6 @@ internal class PluginStatWindow : Window
ImGui.EndTabItem();
}
var toRemove = new List<Guid>();
if (ImGui.BeginTabItem("Hooks"))
{
ImGui.Checkbox("Show Dalamud Hooks", ref this.showDalamudHooks);
@ -291,9 +289,6 @@ internal class PluginStatWindow : Window
{
try
{
if (trackedHook.Hook.IsDisposed)
toRemove.Add(guid);
if (!this.showDalamudHooks && trackedHook.Assembly == Assembly.GetExecutingAssembly())
continue;
@ -355,14 +350,6 @@ internal class PluginStatWindow : Window
}
}
if (ImGui.IsWindowAppearing())
{
foreach (var guid in toRemove)
{
HookManager.TrackedHooks.TryRemove(guid, out _);
}
}
ImGui.EndTabBar();
}
}