ui: Bug fix: ui.funcs might be closed before sending a value

This commit is contained in:
Hajime Hoshi 2016-08-17 01:57:20 +09:00
parent 82d7cee5a3
commit 612d3b07b0

View File

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