Fix crash seen when deleting a 3D view part of a linked view collection

This commit is contained in:
Magne Sjaastad 2023-01-10 15:46:19 +01:00
parent 5a56a285a0
commit b108cdb72d
2 changed files with 13 additions and 2 deletions

View File

@ -65,6 +65,9 @@ void RicDeleteItemExec::redo()
m_commandData.m_deletedObjectAsXml = xmlObj( obj )->writeObjectToXmlString();
}
// Make sure the object is disconnected from other objects before delete
obj->prepareForDelete();
delete obj;
listField->erase( m_commandData.m_indexToObject );

View File

@ -151,7 +151,15 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object )
{
if ( object )
{
PdmUiObjectHandle* uiObject1 = uiObj( m_defaultObjectEditor->pdmObject() );
// Avoid using uiObj( m_defaultObjectEditor->pdmObject() ), as the ui capability can be removed by a
// delete operation. See RicDeleteItemExec::redo() and use of obj->prepareForDelete()
PdmUiObjectHandle* uiObject1 = m_defaultObjectEditor->pdmObject()->capability<PdmUiObjectHandle>();
if ( !uiObject1 )
{
rebuildWidget = true;
m_defaultObjectEditor->setPdmObject( nullptr );
}
PdmUiObjectHandle* uiObject2 = uiObj( object );
if ( uiObject1 && uiObject2 &&
@ -192,7 +200,7 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object )
m_defaultObjectEditor->updateUi( m_uiConfigName );
m_scrollArea->updateGeometry();
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
///