Skip to content

Commit

Permalink
Merge pull request #30684 from qgis/backport-30676-to-release-3_4
Browse files Browse the repository at this point in the history
[Backport release-3_4] Emit valueChanged signal for value relation widget on setFeature
  • Loading branch information
elpaso committed Jul 16, 2019
2 parents b64ef50 + 2feba54 commit c0002b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Expand Up @@ -240,6 +240,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)
Expand Down
5 changes: 5 additions & 0 deletions tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp
Expand Up @@ -165,7 +165,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
Expand Down

0 comments on commit c0002b6

Please sign in to comment.