Skip to content

Commit

Permalink
Merge pull request #164 from RichieSams/protect
Browse files Browse the repository at this point in the history
fix: Protect RenderBlank() and IsFinished() with the lock
  • Loading branch information
schollz committed Feb 24, 2024
2 parents a61e639 + 31e9c17 commit 7b76ca5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions progressbar.go
Expand Up @@ -471,6 +471,9 @@ func (p *ProgressBar) String() string {

// RenderBlank renders the current bar state, you can use this to render a 0% state
func (p *ProgressBar) RenderBlank() error {
p.lock.Lock()
defer p.lock.Unlock()

if p.config.invisible {
return nil
}
Expand Down Expand Up @@ -644,6 +647,9 @@ func (p *ProgressBar) ChangeMax64(newMax int64) {

// IsFinished returns true if progress bar is completed
func (p *ProgressBar) IsFinished() bool {
p.lock.Lock()
defer p.lock.Unlock()

return p.state.finished
}

Expand Down

0 comments on commit 7b76ca5

Please sign in to comment.