mirror of https://github.com/gdamore/tcell.git
Fix data race in tScreen shutdown
Setting t.quit to nil while the mainLoop is running causes a race condition when the Fini() method is called. This change instead uses a select expression to avoid the nil check and set.
This commit is contained in:
parent
23de111f3c
commit
aa381bce1b
|
@ -398,9 +398,12 @@ func (t *tScreen) Fini() {
|
|||
t.clear = false
|
||||
t.fini = true
|
||||
|
||||
if t.quit != nil {
|
||||
select {
|
||||
case <-t.quit:
|
||||
// do nothing, already closed
|
||||
|
||||
default:
|
||||
close(t.quit)
|
||||
t.quit = nil
|
||||
}
|
||||
|
||||
t.termioFini()
|
||||
|
|
Loading…
Reference in New Issue