mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
internal/ui: refactoring: call initOnMainThread on the main thread explicitly
Closes #3042
This commit is contained in:
parent
d4dc2ef5d7
commit
3d385ef0aa
@ -45,10 +45,6 @@ func (u *UserInterface) runMultiThread(game Game, options *RunOptions) error {
|
|||||||
|
|
||||||
u.context = newContext(game)
|
u.context = newContext(game)
|
||||||
|
|
||||||
if err := u.initOnMainThread(options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, cancel := stdcontext.WithCancel(stdcontext.Background())
|
ctx, cancel := stdcontext.WithCancel(stdcontext.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@ -64,6 +60,17 @@ func (u *UserInterface) runMultiThread(game Game, options *RunOptions) error {
|
|||||||
// Run the game thread.
|
// Run the game thread.
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
u.mainThread.Call(func() {
|
||||||
|
if err1 := u.initOnMainThread(options); err1 != nil {
|
||||||
|
err = err1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return u.loopGame()
|
return u.loopGame()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user