light: catch std::stof parse exceptions and log a warning
This commit is contained in:
parent
66184a3849
commit
f6c4309f6d
|
|
@ -167,7 +167,13 @@ public:
|
|||
}
|
||||
|
||||
virtual void setStringValue(const std::string &str, bool locked = false) {
|
||||
const float f = std::stof(str);
|
||||
float f = 0.0f;
|
||||
try {
|
||||
f = std::stof(str);
|
||||
} catch (std::exception &e) {
|
||||
logprint("WARNING: couldn't parse '%s' as number for key '%s'\n",
|
||||
str.c_str(), primaryName().c_str());
|
||||
}
|
||||
if (locked) setFloatValueLocked(f);
|
||||
else setFloatValue(f);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue