mirror of https://github.com/gdamore/tcell.git
fixes #324 Fini() is not idempotent
This commit is contained in:
parent
2323e87243
commit
5216188a4f
|
@ -51,6 +51,8 @@ type cScreen struct {
|
|||
oomode uint32
|
||||
cells CellBuffer
|
||||
|
||||
finiOnce sync.Once
|
||||
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
|
@ -248,6 +250,10 @@ func (s *cScreen) DisableMouse() {
|
|||
}
|
||||
|
||||
func (s *cScreen) Fini() {
|
||||
s.finiOnce.Do(s.finish)
|
||||
}
|
||||
|
||||
func (s *cScreen) finish() {
|
||||
s.Lock()
|
||||
s.style = StyleDefault
|
||||
s.curx = -1
|
||||
|
|
|
@ -113,6 +113,7 @@ type tScreen struct {
|
|||
truecolor bool
|
||||
escaped bool
|
||||
buttondn bool
|
||||
finiOnce sync.Once
|
||||
|
||||
sync.Mutex
|
||||
}
|
||||
|
@ -443,6 +444,10 @@ outer:
|
|||
}
|
||||
|
||||
func (t *tScreen) Fini() {
|
||||
t.finiOnce.Do(t.finish)
|
||||
}
|
||||
|
||||
func (t *tScreen) finish() {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
|
||||
|
|
Loading…
Reference in New Issue