fix: renderer only stops once

Ensure the tea renderer can be stopped and restarted more than once.
This commit is contained in:
Christian Muehlhaeuser 2023-03-06 14:23:51 +01:00
parent 32e3027ec1
commit a136799ed3
1 changed files with 5 additions and 0 deletions

View File

@ -73,7 +73,12 @@ func (r *standardRenderer) start() {
if r.ticker == nil { if r.ticker == nil {
r.ticker = time.NewTicker(r.framerate) r.ticker = time.NewTicker(r.framerate)
} }
// Since the renderer can be restarted after a stop, we need to reset
// the done channel and its corresponding sync.Once.
r.once = sync.Once{}
r.done = make(chan struct{}) r.done = make(chan struct{})
go r.listen() go r.listen()
} }