Skip to content

Commit

Permalink
Merge pull request #7888 from signedav/bugfix_recursive_crash
Browse files Browse the repository at this point in the history
[Bugfix] Do not store recursively
  • Loading branch information
m-kuhn committed Oct 3, 2018
2 parents 2aef195 + dcca348 commit 09adbe2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/gui/editorwidgets/qgsrelationwidgetwrapper.cpp
Expand Up @@ -19,7 +19,6 @@
#include "qgsattributeeditorcontext.h"
#include "qgsproject.h"
#include "qgsrelationmanager.h"

#include <QWidget>

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

void QgsRelationWidgetWrapper::aboutToSave()
{
if ( !mRelation.isValid() || !widget() || !widget()->isVisible() )
if ( !mRelation.isValid() || !widget() || !widget()->isVisible() || mRelation.referencingLayer() == mRelation.referencedLayer() )
return;

// If the layer is already saved before, return
const QgsAttributeEditorContext *ctx = &context();
do
{
if ( ctx->relation().isValid() && ( ctx->relation().referencedLayer() == mRelation.referencingLayer()
|| ( mNmRelation.isValid() && ctx->relation().referencedLayer() == mNmRelation.referencedLayer() ) )
)
{
return;
}
ctx = ctx->parentContext();
}
while ( ctx );

// Calling isModified() will emit a beforeModifiedCheck()
// signal that will make the embedded form to send any
// outstanding widget changes to the edit buffer
Expand Down Expand Up @@ -126,7 +139,6 @@ void QgsRelationWidgetWrapper::initWidget( QWidget *editor )
}
while ( ctx );


w->setRelations( mRelation, mNmRelation );

mWidget = w;
Expand Down

0 comments on commit 09adbe2

Please sign in to comment.