Fix UI Window Memory Leak in CloseRecentWindowUIController (#45399)

no leaking windows
This commit is contained in:
Centronias 2026-08-16 22:38:14 +00:00 • committed by GitHub
parent 8b4a0ff589
commit 68ec95f554
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,6 +27,7 @@ public sealed partial class CloseRecentWindowUIController : UIController
// (Does not need to be unlistened since UIControllers live forever)
_uiManager.OnKeyBindDown += OnKeyBindDown;
_uiManager.WindowRoot.OnChildAdded += OnRootChildAdded;
_uiManager.WindowRoot.OnChildRemoved += OnRootChildRemoved;
_inputManager.SetInputCommand(EngineKeyFunctions.WindowCloseRecent,
InputCmdHandler.FromDelegate(session => CloseMostRecentWindow()));
@ -122,6 +123,14 @@ public sealed partial class CloseRecentWindowUIController : UIController
}
}
private void OnRootChildRemoved(Control control)
{
if (control is BaseWindow window)
{
recentlyInteractedWindows.Remove(window);
}
}
/// <summary>
/// Checks whether there are any windows that can be closed.
/// </summary>