Skip to content

Commit

Permalink
Prevents run stagingUI if OverlappedTop is null.
Browse files Browse the repository at this point in the history
  • Loading branch information
BDisp committed Mar 25, 2024
1 parent feed69d commit 155e0a4
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion UICatalog/Scenarios/BackgroundWorkerCollection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using Terminal.Gui;

Expand All @@ -19,6 +20,10 @@ public override void Init ()

//main.Dispose ();
Application.Top.Dispose ();

#if DEBUG_IDISPOSABLE
Debug.Assert (Application.OverlappedChildren.Count == 0);
#endif
}

public override void Run () { }
Expand Down Expand Up @@ -357,6 +362,12 @@ public WorkerApp ()
Add (_listLog);

Closing += WorkerApp_Closing;
Closed += WorkerApp_Closed;
}

private void WorkerApp_Closed (object sender, ToplevelEventArgs e)
{
CancelWorker ();
}
private void WorkerApp_Closing (object sender, ToplevelClosingEventArgs e)
{
Expand Down Expand Up @@ -475,7 +486,13 @@ public void RunWorker ()
_stagingsUi.Add (stagingUI);
_stagingWorkers.Remove (staging);
#if DEBUG_IDISPOSABLE
if (Application.OverlappedTop is null)
{
stagingUI.Dispose ();
return;
}
#endif
Application.Run (stagingUI);
stagingUI.Dispose ();
}
Expand Down

0 comments on commit 155e0a4

Please sign in to comment.