From 612d3b07b0494dbf3221b3fbf336a711a9b3a61f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 17 Aug 2016 01:57:20 +0900 Subject: [PATCH] ui: Bug fix: ui.funcs might be closed before sending a value --- internal/ui/ui_glfw.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index aca893d0d..f37b9d1e5 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -84,13 +84,10 @@ func (u *userInterface) main(ch <-chan error) error { // TODO: Check this is done on the main thread. for { select { - case f, ok := <-u.funcs: - if ok { - f() - } else { - u.funcs = nil - } + case f := <-u.funcs: + f() case err := <-ch: + // ch returns a value not only when an error occur but also it is closed. return err } } @@ -251,7 +248,6 @@ func (u *userInterface) Terminate() error { glfw.Terminate() return nil }) - close(u.funcs) return nil }