Skip to content
Permalink
Browse files

Reload the data source when a dependency layer is changed (#37751)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
qgis-bot and github-actions committed Jul 15, 2020
1 parent e5e67c3 commit f9e7e3291e074d767a1190460d441c544fbfa02c
@@ -2672,6 +2672,13 @@ Emitted before changes are committed to the data provider.
void beforeRollBack();
%Docstring
Emitted before changes are rolled back.
%End

void afterCommitChanges();
%Docstring
Emitted after changes are commited to the data provider.

.. versionadded:: 3.16
%End

void afterRollBack();
@@ -3354,6 +3354,7 @@ bool QgsVectorLayer::commitChanges()
delete mEditBuffer;
mEditBuffer = nullptr;
undoStack()->clear();
emit afterCommitChanges();
emit editingStopped();
}
else
@@ -5322,6 +5323,12 @@ void QgsVectorLayer::emitDataChanged()
mDataChangedFired = false;
}

void QgsVectorLayer::onAfterCommitChangesDependency()
{
mDataChangedFired = true;
reload();
}

bool QgsVectorLayer::setDependencies( const QSet<QgsMapLayerDependency> &oDeps )
{
QSet<QgsMapLayerDependency> deps;
@@ -5345,6 +5352,7 @@ bool QgsVectorLayer::setDependencies( const QSet<QgsMapLayerDependency> &oDeps )
disconnect( lyr, &QgsVectorLayer::geometryChanged, this, &QgsVectorLayer::emitDataChanged );
disconnect( lyr, &QgsVectorLayer::dataChanged, this, &QgsVectorLayer::emitDataChanged );
disconnect( lyr, &QgsVectorLayer::repaintRequested, this, &QgsVectorLayer::triggerRepaint );
disconnect( lyr, &QgsVectorLayer::afterCommitChanges, this, &QgsVectorLayer::onAfterCommitChangesDependency );
}

// assign new dependencies
@@ -5365,6 +5373,7 @@ bool QgsVectorLayer::setDependencies( const QSet<QgsMapLayerDependency> &oDeps )
connect( lyr, &QgsVectorLayer::geometryChanged, this, &QgsVectorLayer::emitDataChanged );
connect( lyr, &QgsVectorLayer::dataChanged, this, &QgsVectorLayer::emitDataChanged );
connect( lyr, &QgsVectorLayer::repaintRequested, this, &QgsVectorLayer::triggerRepaint );
connect( lyr, &QgsVectorLayer::afterCommitChanges, this, &QgsVectorLayer::onAfterCommitChangesDependency );
}

// if new layers are present, emit a data change
@@ -2482,6 +2482,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
//! Emitted before changes are rolled back.
void beforeRollBack();

/**
* Emitted after changes are commited to the data provider.
* \since QGIS 3.16
*/
void afterCommitChanges();

/**
* Emitted after changes are rolled back.
* \since QGIS 3.4
@@ -2709,6 +2715,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
void onSymbolsCounted();
void onDirtyTransaction( const QString &sql, const QString &name );
void emitDataChanged();
void onAfterCommitChangesDependency();

private:
void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
@@ -872,6 +872,8 @@ void QgsRelationEditorWidget::toggleEditing( bool state )
if ( mNmRelation.isValid() )
mEditorContext.vectorLayerTools()->stopEditing( mNmRelation.referencedLayer() );
}

updateButtons();
}

void QgsRelationEditorWidget::saveEdits()

0 comments on commit f9e7e32

Please sign in to comment.
You can’t perform that action at this time.