]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Dispose storage windows on state change (#20095)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Wed, 13 Sep 2023 22:03:44 +0000 (08:03 +1000)
committerGitHub <noreply@github.com>
Wed, 13 Sep 2023 22:03:44 +0000 (16:03 -0600)
Content.Client/Storage/UI/StorageUIController.cs

index 9fc7909c34923f8fcdda6932e0fbdc6ec7748c4e..352ee4f9edc0efd0170a568c957a3fad6e752db9 100644 (file)
@@ -1,10 +1,11 @@
+using Content.Client.Gameplay;
 using Content.Client.Storage.Systems;
 using Content.Shared.Storage;
 using Robust.Client.UserInterface.Controllers;
 
 namespace Content.Client.Storage.UI;
 
-public sealed class StorageUIController : UIController, IOnSystemChanged<StorageSystem>
+public sealed class StorageUIController : UIController, IOnSystemChanged<StorageSystem>, IOnStateExited<GameplayState>
 {
     // This is mainly to keep legacy functionality for now.
     private readonly Dictionary<EntityUid, StorageWindow> _storageWindows = new();
@@ -57,4 +58,14 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
     {
         system.StorageUpdated -= OnStorageUpdate;
     }
+
+    public void OnStateExited(GameplayState state)
+    {
+        foreach (var window in _storageWindows.Values)
+        {
+            window.Dispose();
+        }
+
+        _storageWindows.Clear();
+    }
 }