Skip to content
Permalink
Browse files

Fixes relation reference widget crash when no relation

  • Loading branch information
pblottiere committed Nov 27, 2017
1 parent 9bfb3f3 commit b1008c7ad195cd515c8699ec5a31a5813ce69070
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp
@@ -64,9 +64,12 @@ void QgsRelationReferenceWidgetWrapper::initWidget( QWidget *editor )
mWidget->setAllowAddFeatures( config( QStringLiteral( "AllowAddFeatures" ), false ).toBool() );

const QVariant relationName = config( QStringLiteral( "Relation" ) );
QgsRelation relation = relationName.isValid() ?
QgsProject::instance()->relationManager()->relation( relationName.toString() ) :
layer()->referencingRelations( fieldIdx() )[0];

QgsRelation relation; // invalid relation by default
if ( relationName.isValid() )
relation = QgsProject::instance()->relationManager()->relation( relationName.toString() );
else if ( ! layer()->referencingRelations( fieldIdx() ).isEmpty() )
relation = layer()->referencingRelations( fieldIdx() )[0];

// If this widget is already embedded by the same relation, reduce functionality
const QgsAttributeEditorContext *ctx = &context();

0 comments on commit b1008c7

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