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:
Enrico 2021-06-29 16:51:25 +02:00 committed by GitHub
parent 6c4edf8605
commit 3ef1d04935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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