From c00c65b044b52027c8ffb131a4c1aff95f8e679a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 20 Sep 2023 11:08:37 +0200 Subject: [PATCH] Fix crash with scaletool For some reason we sometimes get an empty string. This shouldn't crash the application. Fixes sentry crashes: CURA-4CC CURA-4TE CURA-56J --- plugins/Tools/ScaleTool/ScaleTool.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/Tools/ScaleTool/ScaleTool.py b/plugins/Tools/ScaleTool/ScaleTool.py index 3e1b2f573e..af8786c7d4 100644 --- a/plugins/Tools/ScaleTool/ScaleTool.py +++ b/plugins/Tools/ScaleTool/ScaleTool.py @@ -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 @@ -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 @@ -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 @@ -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