瀏覽代碼

Ensures _latestClosedRunStateToplevel is cleanup on ResetState and support OverlappedTop.

BDisp 1 年之前
父節點
當前提交
802b996ed1
共有 1 個文件被更改,包括 15 次插入1 次删除
  1. 15 1
      Terminal.Gui/Application.cs

+ 15 - 1
Terminal.Gui/Application.cs

@@ -101,9 +101,16 @@ public static partial class Application
         if (Top is { })
         {
             Debug.Assert (Top.WasDisposed);
+            // If End wasn't called _latestClosedRunStateToplevel may be null
+            if (_latestClosedRunStateToplevel is { })
+            {
+                Debug.Assert (_latestClosedRunStateToplevel.WasDisposed);
+                Debug.Assert (_latestClosedRunStateToplevel == Top);
+            }
         }
 #endif
         Top = null;
+        _latestClosedRunStateToplevel = null;
 
         // MainLoop stuff
         MainLoop?.Dispose ();
@@ -1064,7 +1071,14 @@ public static partial class Application
         // Don't dispose runState.Toplevel. It's up to caller dispose it
         // If it's not the same as the current in the RunIteration,
         // it will be fixed later in the next RunIteration.
-        _latestClosedRunStateToplevel = runState.Toplevel;
+        if (OverlappedTop is { } && !_topLevels.Contains (OverlappedTop))
+        {
+            _latestClosedRunStateToplevel = OverlappedTop;
+        }
+        else
+        {
+            _latestClosedRunStateToplevel = runState.Toplevel;
+        }
         runState.Toplevel = null;
         runState.Dispose ();
     }