From 8fbc53214920cc8480c63988891e29434e041f25 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 22 Nov 2023 10:25:31 +0100 Subject: [PATCH] Guard missing field for combo box editor This can happen if all summary plots are deleted. The toolbar is still visible, and interaction with toolbar causes crash. --- Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp index 1f51f29ec4..e0a9db744b 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -61,6 +61,8 @@ CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT( PdmUiComboBoxEditor ); //-------------------------------------------------------------------------------------------------- void PdmUiComboBoxEditor::configureAndUpdateUi( const QString& uiConfigName ) { + if ( !uiField() ) return; + if ( !m_label.isNull() ) { PdmUiFieldEditorHandle::updateLabelFromField( m_label, uiConfigName ); @@ -412,6 +414,8 @@ QWidget* PdmUiComboBoxEditor::createLabelWidget( QWidget* parent ) //-------------------------------------------------------------------------------------------------- void PdmUiComboBoxEditor::slotIndexActivated( int index ) { + if ( !uiField() ) return; + uiField()->enableAutoValue( false ); if ( m_attributes.enableEditableContent ) @@ -439,6 +443,8 @@ void PdmUiComboBoxEditor::slotIndexActivated( int index ) //-------------------------------------------------------------------------------------------------- void PdmUiComboBoxEditor::slotEditTextChanged( const QString& text ) { + if ( !uiField() ) return; + if ( text == m_interactiveEditText ) return; uiField()->enableAutoValue( false ); @@ -480,6 +486,8 @@ void PdmUiComboBoxEditor::slotPreviousButtonPressed() //-------------------------------------------------------------------------------------------------- void PdmUiComboBoxEditor::slotApplyAutoValue() { + if ( !uiField() ) return; + bool enable = m_autoValueToolButton->isChecked(); uiField()->enableAutoValue( enable ); configureAndUpdateUi( "" );