In the FreeCAD this can be triggered e.g. by this:
- Create a Pad
- Switch Type to anything
- Switch Type back to Length
Propoused fix:
Code: Select all
diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp
index 4bb599c..fa22b4b 100644
--- a/src/Base/Quantity.cpp
+++ b/src/Base/Quantity.cpp
@@ -73,7 +73,7 @@ bool Quantity::operator ==(const Quantity& that) const
bool Quantity::operator <(const Quantity& that) const
{
- if(this->_Unit != that._Unit)
+ if(!that._Unit.isEmpty() && this->_Unit != that._Unit)
throw Base::Exception("Quantity::operator <(): quantities need to have same unit to compare");
return (this->_Value < that._Value) ;
@@ -81,7 +81,7 @@ bool Quantity::operator <(const Quantity& that) const
bool Quantity::operator >(const Quantity& that) const
{
- if(this->_Unit != that._Unit)
+ if(!that._Unit.isEmpty() && this->_Unit != that._Unit)
throw Base::Exception("Quantity::operator >(): quantities need to have same unit to compare");
return (this->_Value > that._Value) ;
@@ -99,7 +99,7 @@ Quantity Quantity::operator /(const Quantity &p) const
Quantity Quantity::pow(const Quantity &p) const
{
- if(!p._Unit.isEmpty())
+ if(!p._Unit.isEmpty())
throw Base::Exception("Quantity::pow(): exponent must not have a unit");
return Quantity(
std::pow(this->_Value, p._Value),
@@ -109,13 +109,13 @@ Quantity Quantity::pow(const Quantity &p) const
Quantity Quantity::operator +(const Quantity &p) const
{
- if(this->_Unit != p._Unit)
+ if(p._Unit.isEmpty() && this->_Unit != p._Unit)
throw Base::Exception("Quantity::operator +(): Unit mismatch in plus operation");
return Quantity(this->_Value + p._Value,this->_Unit);
}
Quantity Quantity::operator -(const Quantity &p) const
{
- if(this->_Unit != p._Unit)
+ if(p._Unit.isEmpty() && this->_Unit != p._Unit)
throw Base::Exception("Quantity::operator +(): Unit mismatch in minus operation");
return Quantity(this->_Value - p._Value,this->_Unit);
}