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.
This commit is contained in:
1 parent
cb46412049
commit
0fc7a5ed6d
1 file changed
+4
-2
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user