From b494b3c8c04778fad721649fc6ff962aeca4f91b Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 8 Jul 2019 15:46:48 +0200 Subject: [PATCH] ui/app: remove IsAlive IsAlive races with the StageDead event: if the client checks IsAlive after the stage is updated to StageDead but before having received the StageDead it will exit the event loop, blocking the StageDead to ever arrive. Remove IsAlive and let the client rely only on the StageDead to exit its event loop. Signed-off-by: Elias Naur --- ui/app/window.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ui/app/window.go b/ui/app/window.go index ef2898b0..82c3b083 100644 --- a/ui/app/window.go +++ b/ui/app/window.go @@ -79,14 +79,17 @@ func (w *Window) Timings() string { } func (w *Window) SetTextInput(s key.TextInputState) { - if !w.IsAlive() { + w.mu.Lock() + defer w.mu.Unlock() + if !w.isAlive() { return } if s != w.inputState && (s == key.TextInputClose || s == key.TextInputOpen) { w.driver.setTextInput(s) } if s == key.TextInputFocus { - w.Redraw() + w.setNextFrame(time.Time{}) + w.updateAnimation() } w.inputState = s } @@ -221,12 +224,6 @@ func (w *Window) Stage() Stage { return w.stage } -func (w *Window) IsAlive() bool { - w.mu.Lock() - defer w.mu.Unlock() - return w.isAlive() -} - func (w *Window) isAlive() bool { return w.stage > StageDead && w.err == nil }