From 3dfc720878190f75951395bdeb7edee02fdac2f9 Mon Sep 17 00:00:00 2001 From: wolfcomp Date: Sun, 15 Jan 2023 03:52:24 +0100 Subject: [PATCH] feat: add IDisposable support to WindowSystem This is because SamplePlugin contains an example of IDisposable that will never be called when calling RemoveAllWindows or RemoveWindow --- Dalamud/Interface/Windowing/WindowSystem.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/Windowing/WindowSystem.cs b/Dalamud/Interface/Windowing/WindowSystem.cs index 3d53d974e..fbcc60df3 100644 --- a/Dalamud/Interface/Windowing/WindowSystem.cs +++ b/Dalamud/Interface/Windowing/WindowSystem.cs @@ -81,13 +81,25 @@ public class WindowSystem if (!this.windows.Contains(window)) throw new ArgumentException("This window is not registered on this WindowSystem."); + if (window is IDisposable disposable) + disposable.Dispose(); + this.windows.Remove(window); } /// /// Remove all windows from this . /// - public void RemoveAllWindows() => this.windows.Clear(); + public void RemoveAllWindows() + { + foreach (var window in this.windows) + { + if (window is IDisposable disposable) + disposable.Dispose(); + } + + this.windows.Clear(); + } /// /// Get a window by name.