From 540df6c0c09553da384cf88a694c4712dce47c4a Mon Sep 17 00:00:00 2001 From: Julien Cabieces Date: Thu, 11 Jul 2019 16:00:52 +0200 Subject: [PATCH] fixes #30564 : Emit signal for value relation widget so other dependent widgets could be updated --- src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp | 5 +++++ tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp b/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp index 88714f8c1d0..d6fe550c25c 100644 --- a/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp +++ b/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp @@ -277,6 +277,11 @@ void QgsValueRelationWidgetWrapper::setFeature( const QgsFeature &feature ) setFormFeature( feature ); whileBlocking( this )->populate(); whileBlocking( this )->setValue( feature.attribute( fieldIdx() ) ); + + // As we block any signals, possible depending widgets will not being updated + // so we force emit signal once and for all + emitValueChanged(); + // A bit of logic to set the default value if AllowNull is false and this is a new feature // Note that this needs to be here after the cache has been created/updated by populate() // and signals unblocked (we want this to propagate to the feature itself) diff --git a/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp b/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp index 1618de69b63..e7356d88a14 100644 --- a/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp +++ b/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp @@ -175,7 +175,12 @@ void TestQgsValueRelationWidgetWrapper::testDrillDown() QCOMPARE( w_municipality.mCache.size(), 2 ); QCOMPARE( w_municipality.mComboBox->count(), 2 ); + + // check that valueChanged signal is correctly triggered + QSignalSpy spy( &w_municipality, &QgsEditorWidgetWrapper::valueChanged ); + w_municipality.setFeature( f3 ); + QCOMPARE( spy.count(), 1 ); QCOMPARE( w_municipality.mCache.size(), 1 ); // Check first is selected