Skip to content

Commit

Permalink
Fix crash with scaletool
Browse files Browse the repository at this point in the history
For some reason we sometimes get an empty string. This shouldn't crash
the application.

Fixes sentry crashes:
CURA-4CC
CURA-4TE
CURA-56J
  • Loading branch information
nallath committed Sep 20, 2023
1 parent aac43c3 commit c00c65b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions plugins/Tools/ScaleTool/ScaleTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ def setObjectWidth(self, width):

obj = Selection.getSelectedObject(0)
if obj:
width = float(width)
try:
width = float(width)
except ValueError:
Logger.warning("Unable to set width")
return
obj_width = obj.getBoundingBox().width
if not Float.fuzzyCompare(obj_width, width, DIMENSION_TOLERANCE):
scale_factor = width / obj_width
Expand All @@ -341,6 +345,7 @@ def setObjectWidth(self, width):
scale_vector = Vector(scale_factor, scale_factor, scale_factor)

self._scaleSelectedNodes(scale_vector)

def setObjectHeight(self, height):
"""Set the height of the selected object(s) by scaling the first selected object to a certain height
Expand All @@ -349,7 +354,11 @@ def setObjectHeight(self, height):

obj = Selection.getSelectedObject(0)
if obj:
height = float(height)
try:
height = float(height)
except ValueError:
Logger.warning("Unable to set height")
return
obj_height = obj.getBoundingBox().height
if not Float.fuzzyCompare(obj_height, height, DIMENSION_TOLERANCE):
scale_factor = height / obj_height
Expand All @@ -368,7 +377,11 @@ def setObjectDepth(self, depth):

obj = Selection.getSelectedObject(0)
if obj:
depth = float(depth)
try:
depth = float(depth)
except ValueError:
Logger.warning("Unable to set depth")
return
obj_depth = obj.getBoundingBox().depth
if not Float.fuzzyCompare(obj_depth, depth, DIMENSION_TOLERANCE):
scale_factor = depth / obj_depth
Expand Down

0 comments on commit c00c65b

Please sign in to comment.