|
@@ -664,6 +664,15 @@ public static partial class Application
|
|
// by using NotifyStopRunState event.
|
|
// by using NotifyStopRunState event.
|
|
RunLoop (runState);
|
|
RunLoop (runState);
|
|
|
|
|
|
|
|
+ if (runState.Toplevel is null)
|
|
|
|
+ {
|
|
|
|
+#if DEBUG_IDISPOSABLE
|
|
|
|
+ Debug.Assert (_topLevels.Count == 0);
|
|
|
|
+#endif
|
|
|
|
+ runState.Dispose ();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!EndAfterFirstIteration)
|
|
if (!EndAfterFirstIteration)
|
|
{
|
|
{
|
|
End (runState);
|
|
End (runState);
|
|
@@ -802,7 +811,7 @@ public static partial class Application
|
|
|
|
|
|
var firstIteration = true;
|
|
var firstIteration = true;
|
|
|
|
|
|
- for (state.Toplevel.Running = true; state.Toplevel.Running;)
|
|
|
|
|
|
+ for (state.Toplevel.Running = true; state.Toplevel?.Running == true;)
|
|
{
|
|
{
|
|
MainLoop.Running = true;
|
|
MainLoop.Running = true;
|
|
|
|
|
|
@@ -853,6 +862,11 @@ public static partial class Application
|
|
|
|
|
|
firstIteration = false;
|
|
firstIteration = false;
|
|
|
|
|
|
|
|
+ if (Current == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (state.Toplevel != Top && (Top.NeedsDisplay || Top.SubViewNeedsDisplay || Top.LayoutNeeded))
|
|
if (state.Toplevel != Top && (Top.NeedsDisplay || Top.SubViewNeedsDisplay || Top.LayoutNeeded))
|
|
{
|
|
{
|
|
state.Toplevel.SetNeedsDisplay (state.Toplevel.Frame);
|
|
state.Toplevel.SetNeedsDisplay (state.Toplevel.Frame);
|