ProgressWidget: add some bound checks (#3916)

Avoid drawing the fill bar our of the progress bar.
Avoid zero divided by zero that return 'nan' (Not a Number),
that does not bother lua code, but will crash libblitbuffer.so
when it gets nan as a coordinate.
pull/3921/head
poire-z 6 years ago committed by GitHub
parent cb46412049
commit 0fc7a5ed6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -68,10 +68,12 @@ function ProgressWidget:paintTo(bb, x, y)
my_size.w, my_size.h,
self.bordersize, self.bordercolor, self.radius)
-- paint percentage infill
bb:paintRect(x+self.margin_h, math.ceil(y+self.margin_v+self.bordersize),
if self.percentage >= 0 and self.percentage <= 1 then
bb:paintRect(x+self.margin_h, math.ceil(y+self.margin_v+self.bordersize),
math.ceil((my_size.w-2*self.margin_h)*self.percentage),
my_size.h-2*(self.margin_v+self.bordersize), self.rectcolor)
if self.ticks and self.last then
end
if self.ticks and self.last and self.last > 0 then
local bar_width = (my_size.w-2*self.margin_h)
local y_pos = y + self.margin_v + self.bordersize
local bar_height = my_size.h-2*(self.margin_v+self.bordersize)

Loading…
Cancel
Save