From 3ef1d04935a2f731410bc2c180e3f9fa59362494 Mon Sep 17 00:00:00 2001 From: Enrico Date: Tue, 29 Jun 2021 16:51:25 +0200 Subject: [PATCH] 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 --- internal/uidriver/glfw/run_notsinglethread.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/uidriver/glfw/run_notsinglethread.go b/internal/uidriver/glfw/run_notsinglethread.go index ed994c77c..b45c9c2fc 100644 --- a/internal/uidriver/glfw/run_notsinglethread.go +++ b/internal/uidriver/glfw/run_notsinglethread.go @@ -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