From 38d6328e41e383ffadfc132501f92abb3d00b786 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 15 Jul 2024 22:44:30 +0900 Subject: [PATCH] internal/ui: bug fix: crash on Windows Updates #3042 --- internal/ui/run.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/ui/run.go b/internal/ui/run.go index acca963df..c68fb16f7 100644 --- a/internal/ui/run.go +++ b/internal/ui/run.go @@ -37,12 +37,6 @@ func (u *UserInterface) runMultiThread(game Game, options *RunOptions) error { u.mainThread = thread.NewOSThread() graphicscommand.SetOSThreadAsRenderThread() - // Set the running state true after the main thread is set, and before initOnMainThread is called (#2742). - // TODO: As the existence of the main thread is the same as the value of `running`, this is redundant. - // Make `mainThread` atomic and remove `running` if possible. - u.setRunning(true) - defer u.setRunning(false) - u.context = newContext(game) ctx, cancel := stdcontext.WithCancel(stdcontext.Background()) @@ -61,6 +55,12 @@ func (u *UserInterface) runMultiThread(game Game, options *RunOptions) error { wg.Go(func() error { defer cancel() + // Set the running state true after the main thread is set, and before initOnMainThread is called (#2742). + // TODO: As the existence of the main thread is the same as the value of `running`, this is redundant. + // Make `mainThread` atomic and remove `running` if possible. + u.setRunning(true) + defer u.setRunning(false) + var err error u.mainThread.Call(func() { if err1 := u.initOnMainThread(options); err1 != nil {