Skip to content
Permalink
Browse files

check if referencedLayer available

  • Loading branch information
signedav committed Dec 16, 2019
1 parent 995335a commit bfde9609b1d1bfbda235ee276bef35a5c188bde6
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/gui/qgsexpressionbuilderwidget.cpp
@@ -484,8 +484,12 @@ void QgsExpressionBuilderWidget::fillFieldValues( const QString &fieldName, int
// if it's a request for the values of the referenced layer
if ( cbxRelatedLayerValues->isChecked() && setup.config().contains( QStringLiteral( "Relation" ) ) )
{
layer = mProject->relationManager()->relation( setup.config()[QStringLiteral( "Relation" )].toString() ).referencedLayer();
layerFieldIndex = mProject->relationManager()->relation( setup.config()[QStringLiteral( "Relation" )].toString() ).referencedFields().first();
QgsVectorLayer *referencedLayer = mProject->relationManager()->relation( setup.config()[QStringLiteral( "Relation" )].toString() ).referencedLayer();
if ( referencedLayer )
{
layer = referencedLayer;
layerFieldIndex = mProject->relationManager()->relation( setup.config()[QStringLiteral( "Relation" )].toString() ).referencedFields().first();
}
}

QList<QVariant> values = layer->uniqueValues( layerFieldIndex, countLimit ).toList();

0 comments on commit bfde960

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