From 1ed2b09ba0c84711ce9ad0b5294d6ca3643549f3 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 29 Aug 2020 23:27:20 +0900 Subject: [PATCH] uidriver/glfw: Ensure that canceling happens after all the queued tasks are done --- internal/uidriver/glfw/ui.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index 4405427e9..a081d8b61 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -606,7 +606,13 @@ func (u *UserInterface) Run(uicontext driver.UIContext) error { ch := make(chan error, 1) go func() { - defer cancel() + defer func() { + _ = u.t.Call(func() error { + cancel() + return nil + }) + }() + defer close(ch) if err := u.run(); err != nil { ch <- err