From 9efcf9df877f5bc08b98dc19a406bb9d21b68dba Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 26 Jan 2019 10:50:43 -0500 Subject: [PATCH] shape.arc: Prevent an angle underflow when rounded edges are enabled. Fixes #2604 --- lib/gears/shape.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/gears/shape.lua b/lib/gears/shape.lua index b89563c62..6c6bf223e 100644 --- a/lib/gears/shape.lua +++ b/lib/gears/shape.lua @@ -472,8 +472,11 @@ function module.arc(cr, width, height, thickness, start_angle, end_angle, start_ if end_rounded then arc_length = arc_length - thickness/2 - -- And back to angles - end_angle = start_angle + (arc_length/(radius - thickness/2)) + -- And back to angles. Also make sure to avoid underflowing when the + -- rounded edge radius is greater than the angle delta. + end_angle = start_angle + math.max( + 0, arc_length/(radius - thickness/2) + ) end -- The path is a curcular arc joining 4 points