From 8e58f3ce0ae81f350dbb7eef2d7035332de35d8b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 3 Aug 2016 01:07:46 +0900 Subject: [PATCH] ui: Bug fix: closed channel never blocks --- internal/ui/ui_glfw.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 2fbdd1db8..5a6315daf 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -84,8 +84,12 @@ func (u *userInterface) main(ch <-chan error) error { // TODO: Check this is done on the main thread. for { select { - case f := <-u.funcs: - f() + case f, ok := <-u.funcs: + if ok { + f() + } else { + u.funcs = nil + } case err := <-ch: return err } @@ -232,7 +236,6 @@ func (u *userInterface) Terminate() error { return nil }) close(u.funcs) - u.funcs = nil return nil }