From c0678d7aa9a04e8cf1ebf187754179d47a83d224 Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Mon, 25 Oct 2021 07:37:04 -0400 Subject: [PATCH] Fix race condition with locking in SetText Signed-off-by: Sam Whited --- textview.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/textview.go b/textview.go index c4582ec..ba29fdc 100644 --- a/textview.go +++ b/textview.go @@ -281,7 +281,10 @@ func (t *TextView) SetTextColor(color tcell.Color) *TextView { // SetText sets the text of this text view to the provided string. Previously // contained text will be removed. func (t *TextView) SetText(text string) *TextView { - t.Clear() + t.Lock() + defer t.Unlock() + + t.clear() fmt.Fprint(t, text) return t }