浏览代码

Move assertion outside the lock.

BDisp 1 年之前
父节点
当前提交
c5aeac060f
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      Terminal.Gui/Application.cs

+ 9 - 5
Terminal.Gui/Application.cs

@@ -417,15 +417,19 @@ public static partial class Application
             toplevel.EndInit ();
             toplevel.EndInit ();
         }
         }
 
 
+#if DEBUG_IDISPOSABLE
+        if (Top is { } && toplevel != Top && !_topLevels.Contains (Top))
+        {
+            // This assertion confirm if the Top was already disposed
+            Debug.Assert (Top.WasDisposed);
+            Debug.Assert (Top == _latestClosedRunStateToplevel);
+        }
+#endif
+
         lock (_topLevels)
         lock (_topLevels)
         {
         {
             if (Top is { } && toplevel != Top && !_topLevels.Contains (Top))
             if (Top is { } && toplevel != Top && !_topLevels.Contains (Top))
             {
             {
-#if DEBUG_IDISPOSABLE
-                // This assertion confirm if the Top was already disposed
-                Debug.Assert (Top.WasDisposed);
-                Debug.Assert (Top == _latestClosedRunStateToplevel);
-#endif
                 // If Top was already disposed and isn't on the Toplevels Stack,
                 // If Top was already disposed and isn't on the Toplevels Stack,
                 // clean it up here if is the same as _latestClosedRunStateToplevel
                 // clean it up here if is the same as _latestClosedRunStateToplevel
                 if (Top == _latestClosedRunStateToplevel)
                 if (Top == _latestClosedRunStateToplevel)