From 24342eb05d70af48d609a224351237eb1f3d41d2 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 18 Mar 2014 11:50:56 -0400 Subject: 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... --- progressbar.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'progressbar.go') 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 } -- cgit v1.2.3