mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-12 00:06:43 -04:00
Fixes relation reference widget crash when no relation
This commit is contained in:
parent
9bfb3f31ee
commit
b1008c7ad1
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user