Skip to content
Permalink
Browse files

Avoid recursion in ValueRelation widget

Fix #17521
  • Loading branch information
m-kuhn committed Nov 22, 2017
1 parent 58bfbd5 commit 59cf9f329c99a55e05d921bc9c90a1bac81ed3ea
@@ -29,7 +29,6 @@

QgsValueRelationWidgetWrapper::QgsValueRelationWidgetWrapper( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent )
: QgsEditorWidgetWrapper( vl, fieldIdx, editor, parent )
, mUpdating( false )
{
}

@@ -198,12 +197,13 @@ void QgsValueRelationWidgetWrapper::showIndeterminateState()

void QgsValueRelationWidgetWrapper::setEnabled( bool enabled )
{
if ( mUpdating )
if ( mEnabled == enabled )
return;

mEnabled = enabled;

if ( mListWidget )
{
mUpdating = true;
for ( int i = 0; i < mListWidget->count(); ++i )
{
QListWidgetItem *item = mListWidget->item( i );
@@ -213,7 +213,6 @@ void QgsValueRelationWidgetWrapper::setEnabled( bool enabled )
else
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
}
mUpdating = false;
}
else
QgsEditorWidgetWrapper::setEnabled( enabled );
@@ -78,7 +78,7 @@ class GUI_EXPORT QgsValueRelationWidgetWrapper : public QgsEditorWidgetWrapper
QgsValueRelationFieldFormatter::ValueRelationCache mCache;
QgsVectorLayer *mLayer = nullptr;

bool mUpdating;
bool mEnabled = false;

friend class QgsValueRelationWidgetFactory;
friend class TestQgsValueRelationWidgetWrapper;

0 comments on commit 59cf9f3

Please sign in to comment.
You can’t perform that action at this time.