From 68ec95f554bc782fb7f818583f68516a7fe7352d Mon Sep 17 00:00:00 2001 From: Centronias Date: Sun, 16 Aug 2026 22:38:14 +0000 Subject: [PATCH] Fix UI Window Memory Leak in `CloseRecentWindowUIController` (#45399) no leaking windows --- .../Systems/CloseWindow/CloseRecentWindowUIController.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Content.Client/UserInterface/Systems/CloseWindow/CloseRecentWindowUIController.cs b/Content.Client/UserInterface/Systems/CloseWindow/CloseRecentWindowUIController.cs index 8d3e7594ef..f15b235210 100644 --- a/Content.Client/UserInterface/Systems/CloseWindow/CloseRecentWindowUIController.cs +++ b/Content.Client/UserInterface/Systems/CloseWindow/CloseRecentWindowUIController.cs @@ -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); + } + } + /// /// Checks whether there are any windows that can be closed. ///