chiark / gitweb /
Catch errors when print speed is set to out of range numbers
authornickthetait <tait@alephobjects.com>
Thu, 29 Oct 2015 16:13:45 +0000 (10:13 -0600)
committernickthetait <tait@alephobjects.com>
Thu, 29 Oct 2015 16:17:42 +0000 (10:17 -0600)
Fixes T309

Cura/util/validators.py

index c72c4364632640f71403a683e9e636281ed5546e..76f9f2a3c1a347d5a410a55523c7bda3958762f4 100644 (file)
@@ -164,7 +164,13 @@ class printSpeedValidator(object):
                try:
                        nozzleSize = profile.getProfileSettingFloat('nozzle_size')
                        layerHeight = profile.getProfileSettingFloat('layer_height')
-                       printSpeed = float(eval(self.setting.getValue().replace(',','.'), {}, {}))
+                       raw_user_input = self.setting.getValue()
+                       new_print_speed = raw_user_input.replace(',', '.')
+                       try:
+                               evaluated = eval(new_print_speed, {}, {}) #Converts unicode into numeric
+                       except SyntaxError: #Caused by unicode string being empty
+                               evaluated = 0.0
+                       printSpeed = float(evaluated)
                        if printSpeed == 0.0:
                                printSpeed = profile.getProfileSettingFloat('print_speed')