mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 02:29:49 -06:00
Prevent crash when trying to set UIntProperties using Number type (closes #2720)
This commit is contained in:
@@ -45,6 +45,9 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<unsigned int>::operator=;
|
||||
|
||||
private:
|
||||
unsigned int fromLuaConversion(lua_State* state) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -48,4 +48,16 @@ int UIntProperty::typeLua() const {
|
||||
return LUA_TNUMBER;
|
||||
}
|
||||
|
||||
unsigned int UIntProperty::fromLuaConversion(lua_State* state) const {
|
||||
if (ghoul::lua::hasValue<double>(state)) {
|
||||
return static_cast<int>(ghoul::lua::value<double>(state));
|
||||
}
|
||||
else if (ghoul::lua::hasValue<unsigned int>(state)) {
|
||||
return ghoul::lua::value<unsigned int>(state);
|
||||
}
|
||||
else {
|
||||
throw ghoul::RuntimeError(fmt::format("Error extracting value in UIntProperty"));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
Reference in New Issue
Block a user