From 5af5a02e318c2ae4486a9f5f0f3ed54490df6526 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Fri, 24 Jan 2020 00:54:10 +0100 Subject: [PATCH] Fixes ICharacterUI scene controls getting disposed when CharacterInterface is removed. Fixes #550 --- .../Components/Actor/CharacterInterface.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Content.Client/GameObjects/Components/Actor/CharacterInterface.cs b/Content.Client/GameObjects/Components/Actor/CharacterInterface.cs index 789d428a03..816dd89f37 100644 --- a/Content.Client/GameObjects/Components/Actor/CharacterInterface.cs +++ b/Content.Client/GameObjects/Components/Actor/CharacterInterface.cs @@ -36,6 +36,8 @@ namespace Content.Client.GameObjects.Components.Actor /// public SS14Window Window { get; private set; } + private List _uiComponents; + /// /// Create the window with all character UIs and bind it to a keypress /// @@ -44,13 +46,13 @@ namespace Content.Client.GameObjects.Components.Actor base.Initialize(); //Use all the character ui interfaced components to create the character window - var uiComponents = Owner.GetAllComponents().ToList(); - if (uiComponents.Count == 0) + _uiComponents = Owner.GetAllComponents().ToList(); + if (_uiComponents.Count == 0) { return; } - Window = new CharacterWindow(uiComponents); + Window = new CharacterWindow(_uiComponents); Window.OnClose += () => _gameHud.CharacterButtonDown = false; } @@ -61,7 +63,15 @@ namespace Content.Client.GameObjects.Components.Actor { base.OnRemove(); - Window?.Dispose(); + foreach (var component in _uiComponents) + { + // Make sure these don't get deleted when the window is disposed. + component.Scene.Orphan(); + } + + _uiComponents = null; + + Window?.Close(); Window = null; var inputMgr = IoCManager.Resolve();