App: [skip ci] fix Property::isSame() and subclasses by first comparing the pointers directly

This commit is contained in:
wmayer
2022-01-07 17:09:08 +01:00
parent 039d52f01b
commit d3cdd29f5e
7 changed files with 42 additions and 1 deletions

View File

@@ -279,6 +279,8 @@ void Property::setStatus(Status pos, bool on) {
}
bool Property::isSame(const Property &other) const {
if(&other == this)
return true;
if(other.getTypeId() != getTypeId() || getMemSize() != other.getMemSize())
return false;

View File

@@ -32,6 +32,7 @@
#include <string>
#include <bitset>
#include <boost/signals2.hpp>
#include <FCGlobal.h>
namespace Py {
class Object;
@@ -440,7 +441,7 @@ public:
// if the order of the elements in the list relevant?
// if yes, certain operations, like restoring must make sure that the
// order is kept despite errors.
inline void setOrderRelevant(bool on) { this->setStatus(Status::Ordered,on); };
inline void setOrderRelevant(bool on) { this->setStatus(Status::Ordered,on); }
inline bool isOrderRelevant() const { return this->testStatus(Status::Ordered);}
};
@@ -496,6 +497,8 @@ public:
const_reference operator[] (int idx) const {return _lValueList[idx];}
virtual bool isSame(const Property &other) const override {
if (&other == this)
return true;
return this->getTypeId() == other.getTypeId()
&& this->getValue() == static_cast<decltype(this)>(&other)->getValue();
}

View File

@@ -104,6 +104,8 @@ public:
virtual unsigned int getMemSize (void) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& _BaseFileName == static_cast<decltype(this)>(&other)->_BaseFileName
&& _OriginalName == static_cast<decltype(this)>(&other)->_OriginalName

View File

@@ -109,6 +109,8 @@ public:
}
virtual bool isSame(const Property &other) const override {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}
@@ -284,6 +286,8 @@ public:
}
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}
@@ -356,6 +360,8 @@ public:
}
virtual bool isSame(const Property &other) const override {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}

View File

@@ -86,6 +86,8 @@ void PropertyLinkBase::hasSetValue() {
bool PropertyLinkBase::isSame(const Property &other) const
{
if(&other == this)
return true;
if(other.isDerivedFrom(PropertyLinkBase::getClassTypeId())
|| getScope() != static_cast<const PropertyLinkBase*>(&other)->getScope())
return false;

View File

@@ -82,6 +82,8 @@ public:
virtual const boost::any getPathValue(const App::ObjectIdentifier & /*path*/) const { return _lValue; }
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}
@@ -128,6 +130,8 @@ public:
virtual unsigned int getMemSize (void) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}
@@ -228,6 +232,8 @@ public:
virtual bool getPyPathValue(const ObjectIdentifier &path, Py::Object &r) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getEnum() == static_cast<decltype(this)>(&other)->getEnum();
}
@@ -407,6 +413,8 @@ public:
virtual unsigned int getMemSize (void) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValues() == static_cast<decltype(this)>(&other)->getValues();
}
@@ -465,6 +473,8 @@ public:
virtual unsigned int getMemSize (void) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValues() == static_cast<decltype(this)>(&other)->getValues();
}
@@ -519,6 +529,8 @@ public:
const boost::any getPathValue(const App::ObjectIdentifier &path) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}
@@ -708,6 +720,8 @@ public:
const boost::any getPathValue(const App::ObjectIdentifier &path) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getStrValue() == static_cast<decltype(this)>(&other)->getStrValue();
}
@@ -756,6 +770,8 @@ public:
virtual unsigned int getMemSize (void) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& _uuid.getValue() == static_cast<decltype(this)>(&other)->_uuid.getValue();
}
@@ -778,6 +794,8 @@ public:
{ return "Gui::PropertyEditor::PropertyFontItem"; }
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}
@@ -863,6 +881,8 @@ public:
const boost::any getPathValue(const App::ObjectIdentifier &path) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}
@@ -942,6 +962,8 @@ public:
virtual unsigned int getMemSize (void) const{return sizeof(Color);}
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}
@@ -1033,6 +1055,8 @@ public:
virtual unsigned int getMemSize (void) const{return sizeof(_cMat);}
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
}

View File

@@ -72,6 +72,8 @@ public:
virtual const boost::any getPathValue(const App::ObjectIdentifier &path) const;
virtual bool isSame(const Property &other) const {
if (&other == this)
return true;
return getTypeId() == other.getTypeId()
&& getValue() == static_cast<decltype(this)>(&other)->getValue()
&& _Unit == static_cast<decltype(this)>(&other)->_Unit;