diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 56f3421805..bc195831b4 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -797,7 +797,7 @@ void Document::onChanged(const Property* prop) } else if (prop == &UseHasher) { for (auto obj : d->objectArray) { - auto geofeature = dynamic_cast(obj); + auto geofeature = freecad_cast(obj); if (geofeature && geofeature->getPropertyOfGeometry()) { geofeature->enforceRecompute(); } diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 295d491831..cfa8fe077f 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -428,7 +428,7 @@ void DocumentObject::getOutList(int options, std::vector& res) bool noHidden = !!(options & OutListNoHidden); std::size_t size = res.size(); for (auto prop : props) { - auto link = dynamic_cast(prop); + auto link = freecad_cast(prop); if (link) { link->getLinks(res, noHidden); } @@ -457,7 +457,7 @@ std::vector DocumentObject::getOutListOfProperty(App::Prop return ret; } - auto link = dynamic_cast(prop); + auto link = freecad_cast(prop); if (link) { link->getLinks(ret); } @@ -629,7 +629,7 @@ DocumentObject::getPathsByOutList(App::DocumentObject* to) const DocumentObjectGroup* DocumentObject::getGroup() const { - return dynamic_cast(GroupExtension::getGroupOfObject(this)); + return freecad_cast(GroupExtension::getGroupOfObject(this)); } bool DocumentObject::testIfLinkDAGCompatible(DocumentObject* linkTo) const @@ -1130,7 +1130,7 @@ DocumentObject* DocumentObject::getLinkedObject(bool recursive, } } if (transform && mat) { - auto pla = dynamic_cast(getPropertyByName("Placement")); + auto pla = freecad_cast(getPropertyByName("Placement")); if (pla) { *mat *= pla->getValue().toMatrix(); } diff --git a/src/App/ExtensionContainer.h b/src/App/ExtensionContainer.h index 11b97c9054..646ef77ab6 100644 --- a/src/App/ExtensionContainer.h +++ b/src/App/ExtensionContainer.h @@ -180,7 +180,7 @@ public: /// find a property by its name, dynamic cased to specified type template T* getPropertyByName(const char* name) const { - return dynamic_cast(this->getPropertyByName(name)); + return freecad_cast(this->getPropertyByName(name)); } /// get the name of a property const char* getPropertyName(const Property* prop) const override; diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 3820e7a7d1..3d8aaed402 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -482,7 +482,7 @@ PyObject* PropertyContainerPy::getEnumerationsOfProperty(PyObject* args) return nullptr; } - PropertyEnumeration* enumProp = dynamic_cast(prop); + PropertyEnumeration* enumProp = freecad_cast(prop); if (!enumProp) { Py_Return; } diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 2901d72257..6c536ec398 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -88,7 +88,7 @@ void PropertyLinkBase::setReturnNewElement(bool enable) void PropertyLinkBase::hasSetValue() { - auto owner = dynamic_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (owner) { owner->clearOutListCache(); } @@ -1521,7 +1521,7 @@ static bool updateLinkReference(App::PropertyLinkBase* prop, if (!link || !link->isAttachedToDocument()) { return false; } - auto owner = dynamic_cast(prop->getContainer()); + auto owner = freecad_cast(prop->getContainer()); if (owner && owner->isRestoring()) { return false; } @@ -1846,7 +1846,7 @@ void PropertyLinkSub::Save(Base::Writer& writer) const << _cSubList.size(); writer.Stream() << "\">" << std::endl; writer.incInd(); - auto owner = dynamic_cast(getContainer()); + auto owner = freecad_cast(getContainer()); bool exporting = owner && owner->isExporting(); for (unsigned int i = 0; i < _cSubList.size(); i++) { const auto& shadow = _ShadowSubList[i]; @@ -2788,7 +2788,7 @@ void PropertyLinkSubList::Save(Base::Writer& writer) const } writer.Stream() << writer.ind() << "" << endl; writer.incInd(); - auto owner = dynamic_cast(getContainer()); + auto owner = freecad_cast(getContainer()); bool exporting = owner && owner->isExporting(); for (int i = 0; i < getSize(); i++) { auto obj = _lValueList[i]; @@ -2844,7 +2844,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader& reader) SubNames.reserve(count); std::vector shadows; shadows.reserve(count); - DocumentObject* father = dynamic_cast(getContainer()); + DocumentObject* father = freecad_cast(getContainer()); App::Document* document = father ? father->getDocument() : nullptr; std::vector mapped; bool restoreLabel = false; @@ -3609,7 +3609,7 @@ public: for (auto it = links.begin(), itNext = it; it != links.end(); it = itNext) { ++itNext; auto link = *it; - auto obj = dynamic_cast(link->getContainer()); + auto obj = freecad_cast(link->getContainer()); if (obj && obj->getDocument() == &doc) { links.erase(it); // must call unlink here, so that PropertyLink::resetLink can @@ -3654,7 +3654,7 @@ public: bool hasXLink(const App::Document* doc) const { for (auto link : links) { - auto obj = dynamic_cast(link->getContainer()); + auto obj = freecad_cast(link->getContainer()); if (obj && obj->getDocument() == doc) { return true; } @@ -3703,7 +3703,7 @@ void PropertyLinkBase::breakLinks(App::DocumentObject* link, props.clear(); obj->getPropertyList(props); for (auto prop : props) { - auto linkProp = dynamic_cast(prop); + auto linkProp = freecad_cast(prop); if (linkProp) { linkProp->breakLink(link, clear); } @@ -3826,7 +3826,7 @@ void PropertyXLink::restoreLink(App::DocumentObject* lValue) { assert(!_pcLink && lValue && docInfo); - auto owner = dynamic_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (!owner || !owner->isAttachedToDocument()) { throw Base::RuntimeError("invalid container"); } @@ -3863,7 +3863,7 @@ void PropertyXLink::setValue(App::DocumentObject* lValue, throw Base::ValueError("Invalid object"); } - auto owner = dynamic_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (!owner || !owner->isAttachedToDocument()) { throw Base::RuntimeError("invalid container"); } @@ -3930,7 +3930,7 @@ void PropertyXLink::setValue(std::string&& filename, setValue(nullptr, std::move(subs), std::move(shadows)); return; } - auto owner = dynamic_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (!owner || !owner->isAttachedToDocument()) { throw Base::RuntimeError("invalid container"); } diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 3bec6aa2ad..32a0f2e7d4 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1442,7 +1442,7 @@ void PropertyString::setValue(const char* newValue) std::vector>> propChanges; std::string newValueStr = newValue; - auto obj = dynamic_cast(getContainer()); + auto obj = freecad_cast(getContainer()); bool commit = false; if (obj && this == &obj->Label) { @@ -1510,7 +1510,7 @@ void PropertyString::setPyObject(PyObject* value) void PropertyString::Save(Base::Writer& writer) const { std::string val; - auto obj = dynamic_cast(getContainer()); + auto obj = freecad_cast(getContainer()); writer.Stream() << writer.ind() << "isAttachedToDocument() && obj->isExporting() && &obj->Label == this) { @@ -1534,7 +1534,7 @@ void PropertyString::Restore(Base::XMLReader& reader) // read my Element reader.readElement("String"); // get the value of my Attribute - auto obj = dynamic_cast(getContainer()); + auto obj = freecad_cast(getContainer()); if (obj && &obj->Label == this) { if (reader.hasAttribute("restore")) { int restore = reader.getAttributeAsInteger("restore");