From 12d0f273ec108207c87f2f7e767203ad2e6da016 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 11 Oct 2019 22:12:32 +0900 Subject: [PATCH] mobile/ebitenmobileview: Allow to call update before start This fixes an issue that Update on another thread returns error when SetGame is not called. As SetGame is permitted to be called later, Update should not return error. --- mobile/ebitenmobileview/impl_mobile.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mobile/ebitenmobileview/impl_mobile.go b/mobile/ebitenmobileview/impl_mobile.go index 8f62a7672..afca6554c 100644 --- a/mobile/ebitenmobileview/impl_mobile.go +++ b/mobile/ebitenmobileview/impl_mobile.go @@ -22,23 +22,19 @@ package ebitenmobileview import "C" import ( - "errors" - "github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten/internal/uidriver/mobile" ) var ( chError <-chan error - running bool ) func update() error { if chError == nil { - return errors.New("ebitenmobileview: chError must not be nil: Start is not called yet?") - } - if !running { - return errors.New("ebitenmobileview: start must be called ahead of update") + // start is not called yet, but as update can be called from another thread, it is OK. Just ignore + // this. + return nil } select { @@ -52,7 +48,6 @@ func update() error { } func start(f func(*ebiten.Image) error, width, height int, scale float64) { - running = true // The last argument 'title' is not used on mobile platforms, so just pass an empty string. chError = ebiten.RunWithoutMainLoop(f, width, height, scale, "") }