From 4f383de1f596ce404605bb0640689d635fa41a08 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 29 Aug 2019 10:13:42 +0800 Subject: [PATCH] App: ignore unit in PropertyBool/Float/Integer In other word, those property now accept expression result with a unit, by ignoring it. --- src/App/PropertyStandard.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 063d59df99..7c963bad68 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -154,7 +154,7 @@ void PropertyInteger::setPathValue(const ObjectIdentifier &path, const boost::an 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) && boost::any_cast(value).getUnit().isEmpty()) + 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)); @@ -1028,7 +1028,7 @@ void PropertyFloat::setPathValue(const ObjectIdentifier &path, const boost::any if (value.type() == typeid(double)) setValue(boost::any_cast(value)); - else if (value.type() == typeid(Quantity) && boost::any_cast(value).getUnit().isEmpty()) + else if (value.type() == typeid(Quantity)) setValue((boost::any_cast(value)).getValue()); else throw bad_cast(); @@ -2118,7 +2118,7 @@ void PropertyBool::setPathValue(const ObjectIdentifier &path, const boost::any & setValue(boost::any_cast(value) != 0); else if (value.type() == typeid(double)) setValue(boost::math::round(boost::any_cast(value))); - else if (value.type() == typeid(Quantity) && boost::any_cast(value).getUnit().isEmpty()) + else if (value.type() == typeid(Quantity)) setValue(boost::any_cast(value).getValue() != 0); else throw bad_cast();