Skip to content

Commit

Permalink
fix critical bug in progress bar
Browse files Browse the repository at this point in the history
value in pb must not be greater than 100
  • Loading branch information
tzerk committed Feb 27, 2017
1 parent 26141a6 commit 3fa2816
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,17 @@ func observer(
// A wrapper for time.Sleep() that also updates the UI label and progressbar
func wait(config Config, label_Update *ui.Label, pb *ui.ProgressBar) {
tstep := config.TimeBetweenChecksInS
var pbVal int

if tstep <= 0 {
tstep = 1
} // otherwise division by 0
for i := 0; i <= tstep; i++ {
pb.SetValue(int(100/float32(tstep) * float32(i + 1)))
pbVal = int(100/float32(tstep) * float32(i))
if pbVal > 100 {
pbVal = 100
}
pb.SetValue(pbVal)
label_Update.SetText(" Next update in... " + strconv.Itoa(tstep - i) + " s")
time.Sleep(1 * time.Second)
}
Expand Down

0 comments on commit 3fa2816

Please sign in to comment.