From 905fefe87772acdd1f0fb8f1714fead1403dfd97 Mon Sep 17 00:00:00 2001 From: goat Date: Fri, 27 Jan 2023 00:58:04 +0100 Subject: [PATCH] chore: clarify ownership in WindowSystem, deprecate GetWindow(name) --- Dalamud/Interface/Windowing/WindowSystem.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Dalamud/Interface/Windowing/WindowSystem.cs b/Dalamud/Interface/Windowing/WindowSystem.cs index 6c9789735..516f3c21b 100644 --- a/Dalamud/Interface/Windowing/WindowSystem.cs +++ b/Dalamud/Interface/Windowing/WindowSystem.cs @@ -62,6 +62,8 @@ public class WindowSystem /// /// Add a window to this . + /// The window system doesn't own your window, it just renders it + /// You need to store a reference to it to use it later. /// /// The window to add. public void AddWindow(Window window) @@ -74,6 +76,7 @@ public class WindowSystem /// /// Remove a window from this . + /// Will not dispose your window, if it is disposable. /// /// The window to remove. public void RemoveWindow(Window window) @@ -81,31 +84,21 @@ 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 . + /// Will not dispose your windows, if they are disposable. /// - public void RemoveAllWindows() - { - foreach (var window in this.windows) - { - if (window is IDisposable disposable) - disposable.Dispose(); - } - - this.windows.Clear(); - } + public void RemoveAllWindows() => this.windows.Clear(); /// /// Get a window by name. /// /// The name of the . /// The object with matching name or null. + [Obsolete("WindowSystem does not own your window - you should store a reference to it and use that instead.")] public Window? GetWindow(string windowName) => this.windows.FirstOrDefault(w => w.WindowName == windowName); ///