App: Remove assert() from PropertyXLink::Restore
If the property is added to a view provider then in debug mode this will cause a crash while in release mode this will cause undefined behaviour because of a static_cast. To fix crashes remove the assert() and replace the static_cast with freecad_cast.
This commit is contained in:
@@ -4281,14 +4281,12 @@ void PropertyXLink::Restore(Base::XMLReader& reader)
|
||||
name = reader.getAttribute<const char*>("name");
|
||||
}
|
||||
|
||||
assert(getContainer()->isDerivedFrom<App::DocumentObject>());
|
||||
DocumentObject* object = nullptr;
|
||||
if (!name.empty() && file.empty()) {
|
||||
DocumentObject* parent = static_cast<DocumentObject*>(getContainer());
|
||||
Document* document = parent->getDocument();
|
||||
object = document ? document->getObject(name.c_str()) : nullptr;
|
||||
if (!object) {
|
||||
if (reader.isVerbose()) {
|
||||
if (auto parent = freecad_cast<DocumentObject*>(getContainer())) {
|
||||
Document* document = parent->getDocument();
|
||||
object = document ? document->getObject(name.c_str()) : nullptr;
|
||||
if (!object && reader.isVerbose()) {
|
||||
FC_WARN("Lost link to '" << name
|
||||
<< "' while loading, maybe "
|
||||
"an object was not loaded correctly");
|
||||
|
||||
Reference in New Issue
Block a user