mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 01:42:05 +01:00
internal/ui: call setRunning(true) at a more appropriate timing
This commit is contained in:
parent
38d6328e41
commit
f9b0451e08
@ -55,12 +55,6 @@ func (u *UserInterface) runMultiThread(game Game, options *RunOptions) error {
|
|||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
defer cancel()
|
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
|
var err error
|
||||||
u.mainThread.Call(func() {
|
u.mainThread.Call(func() {
|
||||||
if err1 := u.initOnMainThread(options); err1 != nil {
|
if err1 := u.initOnMainThread(options); err1 != nil {
|
||||||
@ -71,6 +65,9 @@ func (u *UserInterface) runMultiThread(game Game, options *RunOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setRunning(true) should be called in initOnMainThread for each platform.
|
||||||
|
defer u.setRunning(false)
|
||||||
|
|
||||||
return u.loopGame()
|
return u.loopGame()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -821,6 +821,8 @@ func (u *UserInterface) createWindow() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
u.window = window
|
u.window = window
|
||||||
|
// Set the running state true just a window is set (#2742).
|
||||||
|
u.setRunning(true)
|
||||||
|
|
||||||
// The position must be set before the size is set (#1982).
|
// The position must be set before the size is set (#1982).
|
||||||
// setWindowSizeInDIP refers the current monitor's device scale.
|
// setWindowSizeInDIP refers the current monitor's device scale.
|
||||||
|
@ -749,6 +749,8 @@ func (u *UserInterface) shouldFocusFirst(options *RunOptions) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
||||||
|
u.setRunning(true)
|
||||||
|
|
||||||
if u.shouldFocusFirst(options) {
|
if u.shouldFocusFirst(options) {
|
||||||
canvas.Call("focus")
|
canvas.Call("focus")
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,8 @@ func (u *UserInterface) init() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
||||||
|
u.setRunning(true)
|
||||||
|
|
||||||
n := C.ebitengine_Initialize()
|
n := C.ebitengine_Initialize()
|
||||||
g, lib, err := newGraphicsDriver(&graphicsDriverCreatorImpl{
|
g, lib, err := newGraphicsDriver(&graphicsDriverCreatorImpl{
|
||||||
nativeWindow: n,
|
nativeWindow: n,
|
||||||
|
@ -69,6 +69,8 @@ func (u *UserInterface) init() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
||||||
|
u.setRunning(true)
|
||||||
|
|
||||||
g, lib, err := newGraphicsDriver(&graphicsDriverCreatorImpl{}, options.GraphicsLibrary)
|
g, lib, err := newGraphicsDriver(&graphicsDriverCreatorImpl{}, options.GraphicsLibrary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user