Skip to content

Commit

Permalink
internal/ui: bug fix: crash on Windows
Browse files Browse the repository at this point in the history
Updates #3042
  • Loading branch information
hajimehoshi committed Jul 15, 2024
1 parent 3d385ef commit 38d6328
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/ui/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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 {
Expand Down

0 comments on commit 38d6328

Please sign in to comment.