light: catch std::stof parse exceptions and log a warning

This commit is contained in:
Eric Wasylishen 2016-09-07 20:04:53 -06:00
parent 66184a3849
commit f6c4309f6d
1 changed files with 7 additions and 1 deletions

View File

@ -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);
}