diff --git a/progressbar.go b/progressbar.go index 1d60be3..b359456 100644 --- a/progressbar.go +++ b/progressbar.go @@ -612,11 +612,17 @@ func New64(max int64) *ProgressBar { // GetMax returns the max of a bar func (p *ProgressBar) GetMax() int { + p.lock.Lock() + defer p.lock.Unlock() + return int(p.config.max) } // GetMax64 returns the current max func (p *ProgressBar) GetMax64() int64 { + p.lock.Lock() + defer p.lock.Unlock() + return p.config.max } @@ -632,6 +638,8 @@ func (p *ProgressBar) ChangeMax(newMax int) { // but takes in a int64 // to avoid casting func (p *ProgressBar) ChangeMax64(newMax int64) { + p.lock.Lock() + p.config.max = newMax if p.config.showBytes { @@ -639,6 +647,8 @@ func (p *ProgressBar) ChangeMax64(newMax int64) { p.config.useIECUnits) } + p.lock.Unlock() // so p.Add can lock + p.Add(0) // re-render }