Skip to content

Commit

Permalink
[GUI] Avoid endless stack of signal emission between QgsFilterLineEdi…
Browse files Browse the repository at this point in the history
…t::valueChanged and QgsValueRelationWidgetWrapper::updateValues() (fixes qgis#55854)
  • Loading branch information
rouault committed Jan 24, 2024
1 parent 31dd35c commit 54aa0d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )
{
connect( filterLineEdit, &QgsFilterLineEdit::valueChanged, this, [ = ]( const QString & )
{
emitValueChanged();
if ( mSubWidgetSignalBlocking == 0 )
emitValueChanged();
} );
}
else
Expand Down Expand Up @@ -399,6 +400,7 @@ void QgsValueRelationWidgetWrapper::updateValues( const QVariant &value, const Q
}
else if ( mLineEdit )
{
mSubWidgetSignalBlocking ++;
mLineEdit->clear();
bool wasFound { false };
for ( const QgsValueRelationFieldFormatter::ValueRelationItem &i : std::as_const( mCache ) )
Expand All @@ -415,6 +417,7 @@ void QgsValueRelationWidgetWrapper::updateValues( const QVariant &value, const Q
{
mLineEdit->setText( tr( "(no selection)" ) );
}
mSubWidgetSignalBlocking --;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class GUI_EXPORT QgsValueRelationWidgetWrapper : public QgsEditorWidgetWrapper
QgsToolTipComboBox *mComboBox = nullptr;
QgsFilteredTableWidget *mTableWidget = nullptr;
QLineEdit *mLineEdit = nullptr;
int mSubWidgetSignalBlocking = 0; //! Set to non-zero when a endless loop of notifications could happen.

QgsValueRelationFieldFormatter::ValueRelationCache mCache;
QgsVectorLayer *mLayer = nullptr;
Expand Down

0 comments on commit 54aa0d9

Please sign in to comment.