From 8030d5639739cc108a14d74cd5d3db45193ab341 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Mon, 27 Apr 2020 11:55:35 +0800 Subject: [PATCH] App: fix some property's setPathValue() --- src/App/PropertyStandard.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 5aed98efe9..fea316a52a 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -152,12 +152,14 @@ void PropertyInteger::setPathValue(const ObjectIdentifier &path, const boost::an if (value.type() == typeid(long)) setValue(boost::any_cast(value)); - else if (value.type() == typeid(double)) - setValue(boost::math::round(boost::any_cast(value))); - else if (value.type() == typeid(Quantity)) - setValue(boost::math::round(boost::any_cast(value).getValue())); else if (value.type() == typeid(int)) setValue(boost::any_cast(value)); + else if (value.type() == typeid(double)) + setValue(boost::math::round(boost::any_cast(value))); + else if (value.type() == typeid(float)) + setValue(boost::math::round(boost::any_cast(value))); + else if (value.type() == typeid(Quantity)) + setValue(boost::math::round(boost::any_cast(value).getValue())); else throw bad_cast(); } @@ -1026,8 +1028,14 @@ void PropertyFloat::setPathValue(const ObjectIdentifier &path, const boost::any { verifyPath(path); - if (value.type() == typeid(double)) + if (value.type() == typeid(long)) + setValue(boost::any_cast(value)); + else if (value.type() == typeid(int)) + setValue(boost::any_cast(value)); + else if (value.type() == typeid(double)) setValue(boost::any_cast(value)); + else if (value.type() == typeid(float)) + setValue(boost::any_cast(value)); else if (value.type() == typeid(Quantity)) setValue((boost::any_cast(value)).getValue()); else if (value.type() == typeid(long)) @@ -1554,8 +1562,12 @@ void PropertyString::setPathValue(const ObjectIdentifier &path, const boost::any setValue(boost::any_cast(value)?"True":"False"); else if (value.type() == typeid(int)) setValue(std::to_string(boost::any_cast(value))); + else if (value.type() == typeid(long)) + setValue(std::to_string(boost::any_cast(value))); else if (value.type() == typeid(double)) - setValue(std::to_string(boost::math::round(App::any_cast(value)))); + setValue(std::to_string(App::any_cast(value))); + else if (value.type() == typeid(float)) + setValue(std::to_string(App::any_cast(value))); else if (value.type() == typeid(Quantity)) setValue(boost::any_cast(value).getUserString().toUtf8().constData()); else if (value.type() == typeid(std::string))