ui: Bug fix: Freezing on calling SetVsyncEnabled

This commit is contained in:
Hajime Hoshi 2018-07-17 02:37:22 +09:00
parent 16c6ab4d07
commit eb68cdad6e

View File

@ -320,10 +320,13 @@ func IsRunnableInBackground() bool {
func SetVsyncEnabled(enabled bool) { func SetVsyncEnabled(enabled bool) {
u := currentUI u := currentUI
if !u.isRunning() { if !u.isRunning() {
_ = u.runOnMainThread(func() error { // In general, m is used for locking init* values.
u.vsync = enabled // m is not used for updating vsync in setScreenSize so far, but
return nil // it should be OK since any goroutines can't reach here when
}) // the game already starts and setScreenSize can be called.
u.m.Lock()
u.vsync = enabled
u.m.Unlock()
return return
} }
_ = u.runOnMainThread(func() error { _ = u.runOnMainThread(func() error {