From 29b5d0b0eb68516ba8f19d25a54744a05b0e41e0 Mon Sep 17 00:00:00 2001 From: daid Date: Mon, 2 Jul 2012 12:25:40 +0200 Subject: [PATCH] Also check for TypeErrors, which seem to happen when you use a comma instead of a dot in values. --- Cura/gui/validators.py | 6 +++--- Cura/util/profile.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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): -- 2.30.2