From: daid Date: Mon, 2 Jul 2012 10:25:40 +0000 (+0200) Subject: Also check for TypeErrors, which seem to happen when you use a comma instead of a... X-Git-Tag: 12.07~19 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=29b5d0b0eb68516ba8f19d25a54744a05b0e41e0;p=cura.git Also check for TypeErrors, which seem to happen when you use a comma instead of a dot in values. --- diff --git a/Cura/gui/validators.py b/Cura/gui/validators.py index f29e8d1e..e37ea946 100644 --- a/Cura/gui/validators.py +++ b/Cura/gui/validators.py @@ -26,7 +26,7 @@ class validFloat(object): if self.maxValue != None and f > self.maxValue: return ERROR, 'This setting should not be above ' + str(self.maxValue) return SUCCESS, '' - except (ValueError, SyntaxError): + except (ValueError, SyntaxError, TypeError): return ERROR, '"' + str(self.setting.GetValue()) + '" is not a valid number or expression' class validInt(object): @@ -44,7 +44,7 @@ class validInt(object): if self.maxValue != None and f > self.maxValue: return ERROR, 'This setting should not be above ' + str(self.maxValue) return SUCCESS, '' - except (ValueError, SyntaxError): + except (ValueError, SyntaxError, TypeError): return ERROR, '"' + str(self.setting.GetValue()) + '" is not a valid whole number or expression' class warningAbove(object): @@ -64,7 +64,7 @@ class warningAbove(object): if f >= self.minValueForWarning: return WARNING, self.warningMessage return SUCCESS, '' - except (ValueError, SyntaxError): + except (ValueError, SyntaxError, TypeError): #We already have an error by the int/float validator in this case. return SUCCESS, '' diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 122b7e90..4c416534 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -267,7 +267,7 @@ def getProfileSetting(name): def getProfileSettingFloat(name): try: return float(eval(getProfileSetting(name), {}, {})) - except (ValueError, SyntaxError): + except (ValueError, SyntaxError, TypeError): return 0.0 def putProfileSetting(name, value): @@ -297,7 +297,7 @@ def getPreferencePath(): def getPreferenceFloat(name): try: return float(eval(getPreference(name), {}, {})) - except (ValueError, SyntaxError): + except (ValueError, SyntaxError, TypeError): return 0.0 def getPreference(name):