Fix race condition panic

This commit is contained in:
Caleb Bassi 2018-12-31 18:37:47 -08:00
parent 43d8b32230
commit ff62b55133
2 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package termui
import (
"image"
"strings"
"sync"
. "github.com/gizak/termui"
)
@ -11,6 +12,8 @@ import (
type Table struct {
*Block
sync.Mutex
Header []string
Rows [][]string
@ -49,6 +52,8 @@ func (self *Table) ColResize() {
// Buffer implements the Bufferer interface.
func (self *Table) Draw(buf *Buffer) {
self.Lock()
self.Block.Draw(buf)
self.ColResizer()
@ -124,6 +129,7 @@ func (self *Table) Draw(buf *Buffer) {
)
}
}
self.Unlock()
}
/////////////////////////////////////////////////////////////////////////////////

View File

@ -66,7 +66,9 @@ func NewProc() *Proc {
go func() {
ticker := time.NewTicker(self.interval)
for range ticker.C {
self.Lock()
self.update()
self.Unlock()
}
}()