mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/uidriver/glfw: Bug fix: do not execute loop function if init failed (#1689)
In `internal/uidriver/glfw/run_notsinglethread.go`, if the `UserInterface.init()` function returns an error, the `loop` is
executed regardless and the error is discarded. This behavior will hide the error returned by `init()` and might trigger
some crashes (see #1688).
A partial fix was implemented in 6c4edf8
, however that commit alone is not enough: the code now is correctly returning
the error via the `ch` channel, but it still executes the `loop()` function. This merge request skips `loop()` call if `init()`
had an error.
Updates #1688
This commit is contained in:
parent
6c4edf8605
commit
3ef1d04935
@ -43,13 +43,12 @@ func (u *UserInterface) Run(uicontext driver.UIContext) error {
|
||||
|
||||
defer close(ch)
|
||||
|
||||
_ = u.t.Call(func() error {
|
||||
if err := u.init(); err != nil {
|
||||
ch <- err
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err := u.t.Call(func() error {
|
||||
return u.init()
|
||||
}); err != nil {
|
||||
ch <- err
|
||||
return
|
||||
}
|
||||
|
||||
if err := u.loop(); err != nil {
|
||||
ch <- err
|
||||
|
Loading…
Reference in New Issue
Block a user