Преглед на файлове

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 ();
         }
 
+#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)
         {
             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,
                 // clean it up here if is the same as _latestClosedRunStateToplevel
                 if (Top == _latestClosedRunStateToplevel)