From: ShadowCommander Date: Tue, 14 May 2024 23:59:46 +0000 (-0700) Subject: Fix salvage magnet UI opening again when activating the console twice (#28010) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=9ea06f3a39a80a250a59396431576fe1bc1ac6dd;p=space-station-14.git Fix salvage magnet UI opening again when activating the console twice (#28010) --- diff --git a/Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs b/Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs index 36fbdd90e2..eafb692733 100644 --- a/Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs +++ b/Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs @@ -20,10 +20,14 @@ public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface protected override void Open() { base.Open(); - _window = new OfferingWindow(); - _window.Title = Loc.GetString("salvage-magnet-window-title"); - _window.OnClose += Close; - _window.OpenCenteredLeft(); + + if (_window is null) + { + _window = new OfferingWindow(); + _window.Title = Loc.GetString("salvage-magnet-window-title"); + _window.OnClose += Close; + _window.OpenCenteredLeft(); + } } protected override void UpdateState(BoundUserInterfaceState state) @@ -108,4 +112,15 @@ public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface _window.AddOption(option); } } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (disposing) + { + _window?.Close(); + _window?.Dispose(); + } + } }