Prevents run iteration if toplevel's stack is empty.

This commit is contained in:
BDisp
2024-03-25 21:56:37 +00:00
parent e764202ff1
commit c8b3e15028

View File

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