~eliasnaur/gio

0be3492e071551d49cbe4a10e098384b55382c4a — Elias Naur 10 months ago 10792f0
ui/app: (wasm) avoid deadlock from focus changes

showTextInput is called from the window loop in window.go, but
could result in an immediate event which then deadlocks waiting for
the window loop to handle it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
1 files changed, 9 insertions(+), 5 deletions(-)

M ui/app/os_js.go
M ui/app/os_js.go => ui/app/os_js.go +9 -5
@@ 318,11 318,15 @@ func (w *window) setAnimating(anim bool) {
}

func (w *window) showTextInput(show bool) {
	if show {
		w.focus()
	} else {
		w.blur()
	}
	// Run in a goroutine to avoid a deadlock if the
	// focus change result in an event.
	go func() {
		if show {
			w.focus()
		} else {
			w.blur()
		}
	}()
}

func (w *window) draw(sync bool) {