mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53:40 +01:00
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
This commit is contained in:
parent
dae1b63797
commit
3dfc720878
1 changed files with 13 additions and 1 deletions
|
|
@ -81,13 +81,25 @@ public class WindowSystem
|
||||||
if (!this.windows.Contains(window))
|
if (!this.windows.Contains(window))
|
||||||
throw new ArgumentException("This window is not registered on this WindowSystem.");
|
throw new ArgumentException("This window is not registered on this WindowSystem.");
|
||||||
|
|
||||||
|
if (window is IDisposable disposable)
|
||||||
|
disposable.Dispose();
|
||||||
|
|
||||||
this.windows.Remove(window);
|
this.windows.Remove(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove all windows from this <see cref="WindowSystem"/>.
|
/// Remove all windows from this <see cref="WindowSystem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a window by name.
|
/// Get a window by name.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue