From b9bd01b79a8b73065396f286f207c919485cb317 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 9 Oct 2022 05:53:02 +0200 Subject: [PATCH] fix: lock renderer during stop/kill --- standard_renderer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/standard_renderer.go b/standard_renderer.go index 195ef59..c0b685d 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -76,7 +76,12 @@ func (r *standardRenderer) start() { // stop permanently halts the renderer, rendering the final frame. func (r *standardRenderer) stop() { + // flush locks the mutex r.flush() + + r.mtx.Lock() + defer r.mtx.Unlock() + r.out.ClearLine() r.once.Do(func() { close(r.done) @@ -91,6 +96,9 @@ func (r *standardRenderer) stop() { // kill halts the renderer. The final frame will not be rendered. func (r *standardRenderer) kill() { + r.mtx.Lock() + defer r.mtx.Unlock() + r.out.ClearLine() r.once.Do(func() { close(r.done)