Fix race condition with locking in SetText

Signed-off-by: Sam Whited <sam@samwhited.com>
This commit is contained in:
Sam Whited 2021-10-25 07:37:04 -04:00
parent 4385df9931
commit c0678d7aa9
1 changed files with 4 additions and 1 deletions

View File

@ -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 // SetText sets the text of this text view to the provided string. Previously
// contained text will be removed. // contained text will be removed.
func (t *TextView) SetText(text string) *TextView { func (t *TextView) SetText(text string) *TextView {
t.Clear() t.Lock()
defer t.Unlock()
t.clear()
fmt.Fprint(t, text) fmt.Fprint(t, text)
return t return t
} }