diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-17 14:09:09 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-17 14:09:09 -0400 |
| commit | 0e8680c04f3b364352a57e686bc93d018c6140e3 (patch) | |
| tree | fbbab88400e8a6060cb59180aa63f2d958b2af52 /progressbar.go | |
| parent | bdb26046b6e91b1cf1a3d752fc36edd059ee5a58 (diff) | |
Dumped the mutex locks from the other controls and elaborated/asked for help in the README.
Diffstat (limited to 'progressbar.go')
| -rw-r--r-- | progressbar.go | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/progressbar.go b/progressbar.go index da89d1a..cd4dc98 100644 --- a/progressbar.go +++ b/progressbar.go @@ -30,9 +30,6 @@ 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") } @@ -40,6 +37,8 @@ func (p *ProgressBar) SetProgress(percent int) { p.sysData.setProgress(percent) return } + p.lock.Lock() + defer p.lock.Unlock() p.initProg = percent } @@ -57,15 +56,9 @@ func (p *ProgressBar) make(window *sysData) error { } func (p *ProgressBar) setRect(x int, y int, width int, height int, winheight int) error { - p.lock.Lock() - defer p.lock.Unlock() - return p.sysData.setRect(x, y, width, height, winheight) } func (p *ProgressBar) preferredSize() (width int, height int) { - p.lock.Lock() - defer p.lock.Unlock() - return p.sysData.preferredSize() } |
