Skip to content

Commit 09adbe2

Browse files
authoredOct 3, 2018
Merge pull request #7888 from signedav/bugfix_recursive_crash
[Bugfix] Do not store recursively
2 parents 2aef195 + dcca348 commit 09adbe2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎src/gui/editorwidgets/qgsrelationwidgetwrapper.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "qgsattributeeditorcontext.h"
2020
#include "qgsproject.h"
2121
#include "qgsrelationmanager.h"
22-
2322
#include <QWidget>
2423

2524
QgsRelationWidgetWrapper::QgsRelationWidgetWrapper( QgsVectorLayer *vl, const QgsRelation &relation, QWidget *editor, QWidget *parent )
@@ -48,9 +47,23 @@ void QgsRelationWidgetWrapper::setVisible( bool visible )
4847

4948
void QgsRelationWidgetWrapper::aboutToSave()
5049
{
51-
if ( !mRelation.isValid() || !widget() || !widget()->isVisible() )
50+
if ( !mRelation.isValid() || !widget() || !widget()->isVisible() || mRelation.referencingLayer() == mRelation.referencedLayer() )
5251
return;
5352

53+
// If the layer is already saved before, return
54+
const QgsAttributeEditorContext *ctx = &context();
55+
do
56+
{
57+
if ( ctx->relation().isValid() && ( ctx->relation().referencedLayer() == mRelation.referencingLayer()
58+
|| ( mNmRelation.isValid() && ctx->relation().referencedLayer() == mNmRelation.referencedLayer() ) )
59+
)
60+
{
61+
return;
62+
}
63+
ctx = ctx->parentContext();
64+
}
65+
while ( ctx );
66+
5467
// Calling isModified() will emit a beforeModifiedCheck()
5568
// signal that will make the embedded form to send any
5669
// outstanding widget changes to the edit buffer
@@ -126,7 +139,6 @@ void QgsRelationWidgetWrapper::initWidget( QWidget *editor )
126139
}
127140
while ( ctx );
128141

129-
130142
w->setRelations( mRelation, mNmRelation );
131143

132144
mWidget = w;

0 commit comments

Comments
 (0)