diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-18 11:50:56 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-18 11:50:56 -0400 |
| commit | 24342eb05d70af48d609a224351237eb1f3d41d2 (patch) | |
| tree | a76faba6d73910fa1f982e58a0f3696c5c702ff8 /progressbar.go | |
| parent | b95d581e86ee57de7c163efa5eb0fb165d0a1032 (diff) | |
Restored the locks everywhere except on resizing calculations. I'll run under the assumption that uitask cannot process any requests while a resize occurs, which means preferredSize() and Stack/Grid.setRect() are inherently safe... let's hope I'm right...
Diffstat (limited to 'progressbar.go')
| -rw-r--r-- | progressbar.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/progressbar.go b/progressbar.go index 80debdc..6ef3f84 100644 --- a/progressbar.go +++ b/progressbar.go @@ -30,6 +30,9 @@ func NewProgressBar() *ProgressBar { // Otherwise, SetProgress panics. // TODO what happens if you repeatedly call SetProgress(-1)? func (p *ProgressBar) SetProgress(percent int) { + p.lock.Lock() + defer p.lock.Unlock() + if percent < -1 || percent > 100 { panic("percent value out of range") } @@ -37,8 +40,6 @@ func (p *ProgressBar) SetProgress(percent int) { p.sysData.setProgress(percent) return } - p.lock.Lock() - defer p.lock.Unlock() p.initProg = percent } |
