App: Use freecad_cast whenever possible
This commit is contained in:
committed by
Benjamin Nauck
parent
929f926846
commit
ad3420e126
@@ -88,7 +88,7 @@ void PropertyLinkBase::setReturnNewElement(bool enable)
|
||||
|
||||
void PropertyLinkBase::hasSetValue()
|
||||
{
|
||||
auto owner = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(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<DocumentObject*>(prop->getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(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<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(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() << "<LinkSubList count=\"" << count << "\">" << endl;
|
||||
writer.incInd();
|
||||
auto owner = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(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<ShadowSub> shadows;
|
||||
shadows.reserve(count);
|
||||
DocumentObject* father = dynamic_cast<DocumentObject*>(getContainer());
|
||||
DocumentObject* father = freecad_cast<DocumentObject*>(getContainer());
|
||||
App::Document* document = father ? father->getDocument() : nullptr;
|
||||
std::vector<int> 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<DocumentObject*>(link->getContainer());
|
||||
auto obj = freecad_cast<DocumentObject*>(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<DocumentObject*>(link->getContainer());
|
||||
auto obj = freecad_cast<DocumentObject*>(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<PropertyLinkBase*>(prop);
|
||||
auto linkProp = freecad_cast<PropertyLinkBase*>(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<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(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<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(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<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(getContainer());
|
||||
if (!owner || !owner->isAttachedToDocument()) {
|
||||
throw Base::RuntimeError("invalid container");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user