Skip to content
Permalink
Browse files

Fix relation editor widget not visible if n:m relation name is empty (#…

…42312) (#42320)

Check relations for equality by Id instead of name and check only if the
relation in context is valid.

Co-authored-by: Damiano <damiano@opengis.ch>
  • Loading branch information
github-actions and domi4484 committed Mar 22, 2021
1 parent c977277 commit 2e888c469c2adf9f03f267ef3e812c3f84f8543c
Showing with 3 additions and 4 deletions.
  1. +3 −4 src/gui/editorwidgets/qgsrelationwidgetwrapper.cpp
@@ -274,17 +274,16 @@ void QgsRelationWidgetWrapper::setNmRelationId( const QVariant &nmRelationId )

// If this widget is already embedded by the same relation, reduce functionality
const QgsAttributeEditorContext *ctx = &context();
do
while ( ctx && ctx->relation().isValid() )
{
if ( ( ctx->relation().name() == mRelation.name() && ctx->formMode() == QgsAttributeEditorContext::Embed )
|| ( mNmRelation.isValid() && ctx->relation().name() == mNmRelation.name() ) )
if ( ( ctx->relation().id() == mRelation.id() && ctx->formMode() == QgsAttributeEditorContext::Embed )
|| ( mNmRelation.isValid() && ctx->relation().id() == mNmRelation.id() ) )
{
mWidget->setVisible( false );
break;
}
ctx = ctx->parentContext();
}
while ( ctx );

mWidget->setRelations( mRelation, mNmRelation );
}

0 comments on commit 2e888c4

Please sign in to comment.