@@ -224,8 +224,10 @@ PropertyLinkList::~PropertyLinkList()
224
224
// before accessing internals make sure the object is not about to be destroyed
225
225
// otherwise the backlink contains dangling pointers
226
226
if (!parent->testStatus (ObjectStatus::Destroy)) {
227
- for (auto *obj : _lValueList)
228
- obj->_removeBackLink (parent);
227
+ for (auto *obj : _lValueList) {
228
+ if (obj)
229
+ obj->_removeBackLink (parent);
230
+ }
229
231
}
230
232
}
231
233
#endif
@@ -251,8 +253,10 @@ void PropertyLinkList::setValue(DocumentObject* lValue)
251
253
// before accessing internals make sure the object is not about to be destroyed
252
254
// otherwise the backlink contains dangling pointers
253
255
if (!parent->testStatus (ObjectStatus::Destroy)) {
254
- for (auto *obj : _lValueList)
255
- obj->_removeBackLink (parent);
256
+ for (auto *obj : _lValueList) {
257
+ if (obj)
258
+ obj->_removeBackLink (parent);
259
+ }
256
260
if (lValue)
257
261
lValue->_addBackLink (parent);
258
262
}
@@ -282,10 +286,14 @@ void PropertyLinkList::setValues(const std::vector<DocumentObject*>& lValue)
282
286
// before accessing internals make sure the object is not about to be destroyed
283
287
// otherwise the backlink contains dangling pointers
284
288
if (!parent->testStatus (ObjectStatus::Destroy)) {
285
- for (auto *obj : _lValueList)
286
- obj->_removeBackLink (parent);
287
- for (auto *obj : lValue)
288
- obj->_addBackLink (parent);
289
+ for (auto *obj : _lValueList) {
290
+ if (obj)
291
+ obj->_removeBackLink (parent);
292
+ }
293
+ for (auto *obj : lValue) {
294
+ if (obj)
295
+ obj->_addBackLink (parent);
296
+ }
289
297
}
290
298
}
291
299
#endif
@@ -651,8 +659,10 @@ PropertyLinkSubList::~PropertyLinkSubList()
651
659
// before accessing internals make sure the object is not about to be destroyed
652
660
// otherwise the backlink contains dangling pointers
653
661
if (!parent->testStatus (ObjectStatus::Destroy)) {
654
- for (auto *obj : _lValueList)
655
- obj->_removeBackLink (parent);
662
+ for (auto *obj : _lValueList) {
663
+ if (obj)
664
+ obj->_removeBackLink (parent);
665
+ }
656
666
}
657
667
}
658
668
#endif
@@ -678,8 +688,10 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue,const char* SubName)
678
688
// before accessing internals make sure the object is not about to be destroyed
679
689
// otherwise the backlink contains dangling pointers
680
690
if (!parent->testStatus (ObjectStatus::Destroy)) {
681
- for (auto *obj : _lValueList)
682
- obj->_removeBackLink (parent);
691
+ for (auto *obj : _lValueList) {
692
+ if (obj)
693
+ obj->_removeBackLink (parent);
694
+ }
683
695
if (lValue)
684
696
lValue->_addBackLink (parent);
685
697
}
@@ -716,13 +728,17 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,c
716
728
if (!parent->testStatus (ObjectStatus::Destroy)) {
717
729
// _lValueList can contain items multiple times, but we trust the document
718
730
// object to ensure that this works
719
- for (auto *obj : _lValueList)
720
- obj->_removeBackLink (parent);
731
+ for (auto *obj : _lValueList) {
732
+ if (obj)
733
+ obj->_removeBackLink (parent);
734
+ }
721
735
722
736
// maintain backlinks. lValue can contain items multiple times, but we trust the document
723
737
// object to ensure that the backlink is only added once
724
- for (auto *obj : lValue)
725
- obj->_addBackLink (parent);
738
+ for (auto *obj : lValue) {
739
+ if (obj)
740
+ obj->_addBackLink (parent);
741
+ }
726
742
}
727
743
}
728
744
#endif
@@ -752,13 +768,17 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,c
752
768
if (!parent->testStatus (ObjectStatus::Destroy)) {
753
769
// _lValueList can contain items multiple times, but we trust the document
754
770
// object to ensure that this works
755
- for (auto *obj : _lValueList)
756
- obj->_removeBackLink (parent);
771
+ for (auto *obj : _lValueList) {
772
+ if (obj)
773
+ obj->_removeBackLink (parent);
774
+ }
757
775
758
776
// maintain backlinks. lValue can contain items multiple times, but we trust the document
759
777
// object to ensure that the backlink is only added once
760
- for (auto *obj : lValue)
761
- obj->_addBackLink (parent);
778
+ for (auto *obj : lValue) {
779
+ if (obj)
780
+ obj->_addBackLink (parent);
781
+ }
762
782
}
763
783
}
764
784
#endif
@@ -780,8 +800,10 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vector<str
780
800
if (!parent->testStatus (ObjectStatus::Destroy)) {
781
801
// _lValueList can contain items multiple times, but we trust the document
782
802
// object to ensure that this works
783
- for (auto *obj : _lValueList)
784
- obj->_removeBackLink (parent);
803
+ for (auto *obj : _lValueList) {
804
+ if (obj)
805
+ obj->_removeBackLink (parent);
806
+ }
785
807
786
808
// maintain backlinks. lValue can contain items multiple times, but we trust the document
787
809
// object to ensure that the backlink is only added once
@@ -1020,10 +1042,18 @@ void PropertyLinkSubList::Save (Base::Writer &writer) const
1020
1042
writer.Stream () << writer.ind () << " <LinkSubList count=\" " << getSize () <<" \" >" << endl;
1021
1043
writer.incInd ();
1022
1044
for (int i = 0 ; i < getSize (); i++) {
1023
- writer.Stream () << writer.ind () <<
1024
- " <Link " <<
1025
- " obj=\" " << _lValueList[i]->getNameInDocument () << " \" " <<
1026
- " sub=\" " << _lSubList[i] << " \" />" << endl;
1045
+ if (_lValueList[i]) {
1046
+ writer.Stream () << writer.ind () <<
1047
+ " <Link " <<
1048
+ " obj=\" " << _lValueList[i]->getNameInDocument () << " \" " <<
1049
+ " sub=\" " << _lSubList[i] << " \" />" << endl;
1050
+ }
1051
+ else {
1052
+ writer.Stream () << writer.ind () <<
1053
+ " <Link " <<
1054
+ " obj=\"\" " <<
1055
+ " sub=\" " << _lSubList[i] << " \" />" << endl;
1056
+ }
1027
1057
}
1028
1058
1029
1059
writer.decInd ();
0 commit comments