#1232 Delete child objects in destructor of ChildField and ChildArrayField

This commit is contained in:
Magne Sjaastad 2017-02-17 11:37:26 +01:00
parent 41fada4d1f
commit 03adf8f759
2 changed files with 2 additions and 13 deletions

View File

@ -15,14 +15,7 @@ namespace caf
template<typename DataType>
PdmChildArrayField<DataType*>::~PdmChildArrayField()
{
#ifdef _DEBUG
for (size_t index = 0; index < m_pointers.size(); ++index)
{
assert(m_pointers.at(index).isNull());
}
#endif
this->removeThisAsParentField();
deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------

View File

@ -52,11 +52,7 @@ caf::PdmChildField<DataType*>::PdmChildField(const DataTypePtr& fieldValue)
template<typename DataType >
caf::PdmChildField<DataType*>::~PdmChildField()
{
bool The_object_owned_by_the_child_field_is_deleted = m_fieldValue.isNull();
assert(The_object_owned_by_the_child_field_is_deleted); // Did you forget ?
if (!m_fieldValue.isNull()) m_fieldValue.rawPtr()->removeAsParentField(this);
m_fieldValue.setRawPtr(NULL);
delete m_fieldValue.rawPtr();
}