From 49ab79219ea16a9071f9a24fbc966e60a5e6ae1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 25 Sep 2015 14:42:12 +0200 Subject: [PATCH] Fixed crashes regarding general handling of NULL pointers in Child Arrays --- .../cafPdmCore/cafPdmChildArrayField.inl | 7 ++++--- .../cafPdmUiCore/cafPdmUiObjectHandle.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl index 37ed647492..e19efa87e4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl @@ -134,11 +134,12 @@ void PdmChildArrayField::deleteAllChildObjects() template void PdmChildArrayField::erase(size_t index) { - PdmObjectHandle* obj = m_pointers[index].rawPtr(); - if (obj) + if (m_pointers[index].rawPtr()) { - removeChildObject(obj); + m_pointers[index].rawPtr()->removeAsParentField(this); } + + m_pointers.erase(m_pointers.begin() + index); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp index 3f067d8a9f..3b4a205e4a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp @@ -121,7 +121,7 @@ void PdmUiObjectHandle::addDefaultUiTreeChildren(PdmUiTreeOrdering* uiTreeOrderi for (size_t cIdx = 0; cIdx < children.size(); cIdx++) { - if (!uiTreeOrdering->containsObject(children[cIdx])) + if (children[cIdx] && !uiTreeOrdering->containsObject(children[cIdx])) { uiTreeOrdering->add(children[cIdx]); }