#11731 Detect when a group box have the same name as an existing group box

Detect when a group box have the same name as an existing group box. This is not currently supported, and leads to dangling group boxes in the Property Editor.

Trigger assert and crash when the situation appears.
This commit is contained in:
Magne Sjaastad 2024-10-01 12:08:26 +02:00
parent 0a0c8fbbe3
commit da37687c77

View File

@ -348,6 +348,17 @@ QMinimizePanel* caf::PdmUiFormLayoutObjectEditor::findOrCreateGroupBox( QWidget*
if ( it == m_groupBoxes.end() )
{
auto newBoxIt = m_newGroupBoxes.find( groupBoxKey );
if ( newBoxIt != m_newGroupBoxes.end() )
{
// This error happens when the same group is added to the same parent multiple times
// https://github.com/OPM/ResInsight/issues/11731
// Suggested approach: Make sure that all objects and groups in PdmUiOrdering have unique names.
auto message = "Detected duplicate group box with keyword: " + groupBoxKey;
CAF_ASSERT( false && message.toStdString().data() );
}
groupBox = new QMinimizePanel( parent );
groupBox->enableFrame( group->enableFrame() );
groupBox->setTitle( group->uiName( uiConfigName ) );