mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
ebiten: bug fix: updating the input state must be protected by a mutex
This commit is contained in:
parent
b79f0394cc
commit
40aa35750c
@ -148,7 +148,7 @@ func (g *gameForUI) Layout(outsideWidth, outsideHeight float64) (float64, float6
|
||||
}
|
||||
|
||||
func (g *gameForUI) UpdateInputState(fn func(*ui.InputState)) {
|
||||
fn(&theInputState.state)
|
||||
theInputState.update(fn)
|
||||
}
|
||||
|
||||
func (g *gameForUI) Update() error {
|
||||
|
4
input.go
4
input.go
@ -396,10 +396,10 @@ type inputState struct {
|
||||
m sync.Mutex
|
||||
}
|
||||
|
||||
func (i *inputState) set(inputState ui.InputState) {
|
||||
func (i *inputState) update(fn func(*ui.InputState)) {
|
||||
i.m.Lock()
|
||||
defer i.m.Unlock()
|
||||
i.state = inputState
|
||||
fn(&i.state)
|
||||
}
|
||||
|
||||
func (i *inputState) appendInputChars(runes []rune) []rune {
|
||||
|
Loading…
Reference in New Issue
Block a user