mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-05 19:46:17 +08:00
Also check for TypeErrors, which seem to happen when you use a comma instead of a dot in values.
This commit is contained in:
parent
402c2223ca
commit
29b5d0b0eb
@ -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, ''
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user