#13256 Framework: Make sure labels and buttons are deleted

Make sure standalone labels and buttons are deleted between multiple calls to defineUiOrdering.
This commit is contained in:
Magne Sjaastad authored and Kristian Bendiksen committed 2025-12-01 14:10:34 +01:00
1 parent c035c31a0d
commit f230998fff
2 files changed
+29 -17

No files matched your search

@@ -624,33 +624,43 @@ void caf::PdmUiFormLayoutObjectEditor::cleanupBeforeSettingPdmObject()
m_groupBoxes.clear();
for ( auto& label : m_labels )
{
if ( label )
{
delete label;
}
}
m_labels.clear();
for ( auto& button : m_buttons )
{
if ( button )
{
delete button;
}
}
m_buttons.clear();
deleteLabelsAndButtons();
// Note: Layouts are now managed by Qt's parent-child ownership system.
// When added to parent layouts via addLayout(), Qt automatically handles cleanup.
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::PdmUiFormLayoutObjectEditor::deleteLabelsAndButtons()
{
for ( auto& label : m_labels )
{
if ( label )
{
label->deleteLater();
}
}
m_labels.clear();
for ( auto& button : m_buttons )
{
if ( button )
{
button->deleteLater();
}
}
m_buttons.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::PdmUiFormLayoutObjectEditor::configureAndUpdateUi( const QString& uiConfigName )
{
deleteLabelsAndButtons();
caf::PdmUiOrdering config;
if ( pdmObject() )
{
@@ -111,6 +111,8 @@ private:
QLabel* createLabel( QWidget* parent, const PdmUiLabel& label, const QString& uiConfigName );
QPushButton* createButton( QWidget* parent, const PdmUiButton& button, const QString& uiConfigName );
void deleteLabelsAndButtons();
private:
std::map<PdmFieldHandle*, PdmUiFieldEditorHandle*> m_fieldViews;
std::set<PdmFieldHandle*> m_usedFields; ///< used temporarily to store the new(complete) set of used fields