diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index b82f4b452ebb..83e72b39f710 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -224,8 +224,10 @@ PropertyLinkList::~PropertyLinkList() // before accessing internals make sure the object is not about to be destroyed // otherwise the backlink contains dangling pointers if (!parent->testStatus(ObjectStatus::Destroy)) { - for(auto *obj : _lValueList) - obj->_removeBackLink(parent); + for(auto *obj : _lValueList) { + if (obj) + obj->_removeBackLink(parent); + } } } #endif @@ -251,8 +253,10 @@ void PropertyLinkList::setValue(DocumentObject* lValue) // before accessing internals make sure the object is not about to be destroyed // otherwise the backlink contains dangling pointers if (!parent->testStatus(ObjectStatus::Destroy)) { - for(auto *obj : _lValueList) - obj->_removeBackLink(parent); + for(auto *obj : _lValueList) { + if (obj) + obj->_removeBackLink(parent); + } if (lValue) lValue->_addBackLink(parent); } @@ -282,10 +286,14 @@ void PropertyLinkList::setValues(const std::vector& lValue) // before accessing internals make sure the object is not about to be destroyed // otherwise the backlink contains dangling pointers if (!parent->testStatus(ObjectStatus::Destroy)) { - for(auto *obj : _lValueList) - obj->_removeBackLink(parent); - for(auto *obj : lValue) - obj->_addBackLink(parent); + for(auto *obj : _lValueList) { + if (obj) + obj->_removeBackLink(parent); + } + for(auto *obj : lValue) { + if (obj) + obj->_addBackLink(parent); + } } } #endif @@ -651,8 +659,10 @@ PropertyLinkSubList::~PropertyLinkSubList() // before accessing internals make sure the object is not about to be destroyed // otherwise the backlink contains dangling pointers if (!parent->testStatus(ObjectStatus::Destroy)) { - for(auto *obj : _lValueList) - obj->_removeBackLink(parent); + for(auto *obj : _lValueList) { + if (obj) + obj->_removeBackLink(parent); + } } } #endif @@ -678,8 +688,10 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue,const char* SubName) // before accessing internals make sure the object is not about to be destroyed // otherwise the backlink contains dangling pointers if (!parent->testStatus(ObjectStatus::Destroy)) { - for(auto *obj : _lValueList) - obj->_removeBackLink(parent); + for(auto *obj : _lValueList) { + if (obj) + obj->_removeBackLink(parent); + } if (lValue) lValue->_addBackLink(parent); } @@ -716,13 +728,17 @@ void PropertyLinkSubList::setValues(const std::vector& lValue,c if (!parent->testStatus(ObjectStatus::Destroy)) { //_lValueList can contain items multiple times, but we trust the document //object to ensure that this works - for(auto *obj : _lValueList) - obj->_removeBackLink(parent); + for(auto *obj : _lValueList) { + if (obj) + obj->_removeBackLink(parent); + } //maintain backlinks. lValue can contain items multiple times, but we trust the document //object to ensure that the backlink is only added once - for(auto *obj : lValue) - obj->_addBackLink(parent); + for(auto *obj : lValue) { + if (obj) + obj->_addBackLink(parent); + } } } #endif @@ -752,13 +768,17 @@ void PropertyLinkSubList::setValues(const std::vector& lValue,c if (!parent->testStatus(ObjectStatus::Destroy)) { //_lValueList can contain items multiple times, but we trust the document //object to ensure that this works - for(auto *obj : _lValueList) - obj->_removeBackLink(parent); + for(auto *obj : _lValueList) { + if (obj) + obj->_removeBackLink(parent); + } //maintain backlinks. lValue can contain items multiple times, but we trust the document //object to ensure that the backlink is only added once - for(auto *obj : lValue) - obj->_addBackLink(parent); + for(auto *obj : lValue) { + if (obj) + obj->_addBackLink(parent); + } } } #endif @@ -780,8 +800,10 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vectortestStatus(ObjectStatus::Destroy)) { //_lValueList can contain items multiple times, but we trust the document //object to ensure that this works - for(auto *obj : _lValueList) - obj->_removeBackLink(parent); + for(auto *obj : _lValueList) { + if (obj) + obj->_removeBackLink(parent); + } //maintain backlinks. lValue can contain items multiple times, but we trust the document //object to ensure that the backlink is only added once @@ -1020,10 +1042,18 @@ void PropertyLinkSubList::Save (Base::Writer &writer) const writer.Stream() << writer.ind() << "" << endl; writer.incInd(); for (int i = 0; i < getSize(); i++) { - writer.Stream() << writer.ind() << - "getNameInDocument() << "\" " << - "sub=\"" << _lSubList[i] << "\"/>" << endl; + if (_lValueList[i]) { + writer.Stream() << writer.ind() << + "getNameInDocument() << "\" " << + "sub=\"" << _lSubList[i] << "\"/>" << endl; + } + else { + writer.Stream() << writer.ind() << + "" << endl; + } } writer.decInd();