- solved a ZeroDivisionError exception in the Geometry Editor -> Path Tool

This commit is contained in:
Marius Stanciu
2022-04-14 14:24:53 +03:00
committed by Marius
parent 53c92306dd
commit a09700929e
2 changed files with 4 additions and 1 deletions

View File

@@ -1086,13 +1086,15 @@ class FCPath(FCPolygon):
last_pt = self.draw_app.app.mouse
seg_length = math.sqrt((last_pt[0] - first_pt[0])**2 + (last_pt[1] - first_pt[1])**2)
if seg_length == 0.0:
return
try:
new_x = first_pt[0] + (last_pt[0] - first_pt[0]) / seg_length * target_length
new_y = first_pt[1] + (last_pt[1] - first_pt[1]) / seg_length * target_length
except ZeroDivisionError as err:
self.points = []
self.clean_up()
return '%s %s' % (_("Failed."), str(err))
return '[ERROR_NOTCL] %s %s' % (_("Failed."), str(err).capitalize())
if self.points[-1] != (new_x, new_y):
self.points.append((new_x, new_y))