Skip to content

Commit eb3b5f1

Browse files
magnesjkriben
authored andcommitted
#14178 Fix crash in slider editor from re-entrant field write
The integer slider editor cross-updated the spin box and slider without blocking signals, so a single user interaction wrote to the PDM field twice. The first (nested) write could trigger a field-changed callback that rebuilt the property panel and destroyed the spin box internal line edit, after which the second write dereferenced the dangling line edit in QAbstractSpinBox::text() and crashed. Block the other widget signals while programmatically syncing in slotSliderValueChanged and updateSliderPosition, restoring the previous blocked state so it nests safely with configureAndUpdateUi. Add null guards in updateSliderPosition and writeValueToField.
1 parent 25921d1 commit eb3b5f1

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ QWidget* PdmUiSliderEditor::createEditorWidget( QWidget* parent )
151151
//--------------------------------------------------------------------------------------------------
152152
void PdmUiSliderEditor::slotSliderValueChanged( int position )
153153
{
154-
m_spinBox->setValue( position );
154+
if ( m_spinBox )
155+
{
156+
// Block signals to avoid re-entering slotSpinBoxValueChanged(), which would write to the
157+
// field a second time and may tear down this editor's widgets while we are still executing.
158+
bool wasBlocked = m_spinBox->blockSignals( true );
159+
m_spinBox->setValue( position );
160+
m_spinBox->blockSignals( wasBlocked );
161+
}
155162

156163
writeValueToField();
157164
}
@@ -171,14 +178,21 @@ void PdmUiSliderEditor::slotSpinBoxValueChanged( int spinBoxValue )
171178
//--------------------------------------------------------------------------------------------------
172179
void PdmUiSliderEditor::updateSliderPosition()
173180
{
181+
if ( m_spinBox.isNull() || m_slider.isNull() ) return;
182+
174183
QString textValue = m_spinBox->text();
175184

176185
bool convertOk = false;
177186
int newSliderValue = textValue.toInt( &convertOk );
178187
if ( convertOk )
179188
{
180189
newSliderValue = qBound( m_attributes.m_minimum, newSliderValue, m_attributes.m_maximum );
190+
191+
// Block signals to avoid re-entering slotSliderValueChanged(), which would write to the
192+
// field a second time and may tear down this editor's widgets while we are still executing.
193+
bool wasBlocked = m_slider->blockSignals( true );
181194
m_slider->setValue( newSliderValue );
195+
m_slider->blockSignals( wasBlocked );
182196
}
183197
}
184198

@@ -187,6 +201,8 @@ void PdmUiSliderEditor::updateSliderPosition()
187201
//--------------------------------------------------------------------------------------------------
188202
void PdmUiSliderEditor::writeValueToField()
189203
{
204+
if ( m_spinBox.isNull() ) return;
205+
190206
QString textValue = m_spinBox->text();
191207
QVariant v;
192208
v = textValue;

0 commit comments

Comments
 (0)