Skip to content
Permalink
Browse files

Fix QgsAbstractRelationEditorWidget redondancy mNmRelation/nNmRelationId

mNmRelation and nNmRelationId represent the same QgsRelation instance
but it was possible to set them to different values.
Also added method nmRelation() to access the nmRelation directly.
  • Loading branch information
domi4484 committed Mar 17, 2021
1 parent 64d04ed commit fad9d75a71131c59b62d3215228b3a0c9e1a0ec9
@@ -61,6 +61,13 @@ inserting and deleting entries on the intermediate table as required.
%Docstring
Returns the relation

.. versionadded:: 3.18
%End

QgsRelation nmRelation() const;
%Docstring
Returns the nm relation

.. versionadded:: 3.18
%End

@@ -268,8 +268,6 @@ void QgsRelationWidgetWrapper::setNmRelationId( const QVariant &nmRelationId )
{
if ( mWidget )
{
mWidget->setNmRelationId( nmRelationId );

mNmRelation = QgsProject::instance()->relationManager()->relation( nmRelationId.toString() );

// If this widget is already embedded by the same relation, reduce functionality
@@ -22,6 +22,7 @@
#include "qgsfeature.h"
#include "qgsfeatureselectiondlg.h"
#include "qgsrelation.h"
#include "qgsrelationmanager.h"
#include "qgspolymorphicrelation.h"
#include "qgsvectorlayertools.h"
#include "qgsproject.h"
@@ -116,12 +117,14 @@ void QgsAbstractRelationEditorWidget::setFeature( const QgsFeature &feature, boo

void QgsAbstractRelationEditorWidget::setNmRelationId( const QVariant &nmRelationId )
{
mNmRelationId = nmRelationId;
QgsRelation nmrelation = QgsProject::instance()->relationManager()->relation( nmRelationId.toString() );
beforeSetRelations( mRelation, nmrelation );
mNmRelation = nmrelation;
}

QVariant QgsAbstractRelationEditorWidget::nmRelationId() const
{
return mNmRelationId;
return mNmRelation.id();
}

QString QgsAbstractRelationEditorWidget::label() const
@@ -86,6 +86,12 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
*/
QgsRelation relation() const {return mRelation;}

/**
* Returns the nm relation
* \since QGIS 3.18
*/
QgsRelation nmRelation() const {return mNmRelation;}

/**
* Sets the \a feature being edited and updates the UI unless \a update is set to FALSE
*/
@@ -226,7 +232,6 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
bool mLayerInSameTransactionGroup = false;

bool mForceSuppressFormPopup = false;
QVariant mNmRelationId;
QString mLabel;

/**

0 comments on commit fad9d75

Please sign in to comment.