Skip to content

Commit 6e2942f

Browse files
committed
Fix exception when exiting with MapForm or SoundDebugForm open.
Bug #2127145.
1 parent e57a7a1 commit 6e2942f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Source/RunActivity/Viewer3D/Processes/GameStateViewer3D.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ internal override void Dispose()
131131
MPManager.Client.Stop();
132132
if (Program.Simulator != null)
133133
Program.Simulator.Stop();
134-
if (Program.MapForm != null)
135-
Program.MapForm.Dispose();
136-
if (Program.SoundDebugForm != null)
137-
Program.SoundDebugForm.Dispose();
134+
// MapForm and SoundDebugForm run in the Renderer thread and need to be disposed there
138135
base.Dispose();
139136
}
140137

Source/RunActivity/Viewer3D/Processes/RenderProcess.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,12 @@ internal void EndDraw()
359359
internal void Stop()
360360
{
361361
Game.WatchdogProcess.Unregister(WatchdogToken);
362+
363+
// these run in the Renderer thread, and thus cannot be disposed in GameStateViewer3D
364+
if (Program.MapForm != null)
365+
Program.MapForm.Dispose();
366+
if (Program.SoundDebugForm != null)
367+
Program.SoundDebugForm.Dispose();
362368
}
363369

364370
static void SwapFrames(ref RenderFrame frame1, ref RenderFrame frame2)

0 commit comments

Comments
 (0)