diff --git a/src/gui/qgsattributeform.cpp b/src/gui/qgsattributeform.cpp index e01faa1fb9a5..ae7362c67286 100644 --- a/src/gui/qgsattributeform.cpp +++ b/src/gui/qgsattributeform.cpp @@ -1045,9 +1045,8 @@ void QgsAttributeForm::onAttributeChanged( const QVariant &value, const QVariant if ( formEditorWidget->editorWidget() == eww ) continue; - // formEditorWidget and eww points to the same field, so block signals - // as there is no need to handle valueChanged again for each duplicate - whileBlocking( formEditorWidget->editorWidget() )->setValue( value ); + // formEditorWidget and eww points to the same field, so update its value + formEditorWidget->editorWidget()->setValue( value ); } switch ( mMode ) diff --git a/tests/src/gui/testqgsdualview.cpp b/tests/src/gui/testqgsdualview.cpp index 49976a28a187..71945243dd79 100644 --- a/tests/src/gui/testqgsdualview.cpp +++ b/tests/src/gui/testqgsdualview.cpp @@ -438,11 +438,31 @@ void TestQgsDualView::testDuplicateField() const QList formEditorWidgets = dualView.mAttributeForm->mFormEditorWidgets.values( 0 ); + // reset mIsChanged state + formEditorWidgets[0]->changesCommitted(); + formEditorWidgets[1]->changesCommitted(); + QVERIFY( !formEditorWidgets[0]->hasChanged() ); + QVERIFY( !formEditorWidgets[1]->hasChanged() ); + formEditorWidgets[0]->editorWidget()->setValues( 20, QVariantList() ); + QCOMPARE( formEditorWidgets[0]->editorWidget()->value().toInt(), 20 ); + QCOMPARE( formEditorWidgets[1]->editorWidget()->value().toInt(), 20 ); + QVERIFY( formEditorWidgets[0]->hasChanged() ); + QVERIFY( formEditorWidgets[1]->hasChanged() ); ft = layer->getFeature( ft.id() ); QCOMPARE( ft.attribute( QStringLiteral( "col0" ) ).toInt(), 20 ); + // reset mIsChanged state + formEditorWidgets[0]->changesCommitted(); + formEditorWidgets[1]->changesCommitted(); + QVERIFY( !formEditorWidgets[0]->hasChanged() ); + QVERIFY( !formEditorWidgets[1]->hasChanged() ); + formEditorWidgets[1]->editorWidget()->setValues( 21, QVariantList() ); + QCOMPARE( formEditorWidgets[0]->editorWidget()->value().toInt(), 21 ); + QCOMPARE( formEditorWidgets[1]->editorWidget()->value().toInt(), 21 ); + QVERIFY( formEditorWidgets[0]->hasChanged() ); + QVERIFY( formEditorWidgets[1]->hasChanged() ); ft = layer->getFeature( ft.id() ); QCOMPARE( ft.attribute( QStringLiteral( "col0" ) ).toInt(), 21 );