From 527359bc7cc24490042db7bd460ec2da92d868d8 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Tue, 14 Dec 2021 22:19:34 +0200 Subject: [PATCH] Fix misleading docs that is only valid if edit buffer is used (so does not work in transaction mode) Long story short, the `layer.committedFeaturesAdded` signal is not fired after `layer.commitChanges()` when in transaction mode. If the layer is using the `QgsVectorLayerEditBuffer` the `commitedFeaturesAdded` signal is fired. But if transaction is used and the `layer.editBuffer()` returns `QgsVectorLayerEditPasstrough`, then there is no signal. The `QgsVectorLayerEditPasstrough` class is quite empty and lacking implementation of these events, so they don't work on layers in a transaction group. --- .../core/auto_generated/vector/qgsvectorlayer.sip.in | 12 ++++++------ src/core/vector/qgsvectorlayer.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python/core/auto_generated/vector/qgsvectorlayer.sip.in b/python/core/auto_generated/vector/qgsvectorlayer.sip.in index d0da45fc9b2..2270d283452 100644 --- a/python/core/auto_generated/vector/qgsvectorlayer.sip.in +++ b/python/core/auto_generated/vector/qgsvectorlayer.sip.in @@ -2891,27 +2891,27 @@ Note that at this point the geometry change is not yet saved to the provider. void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes ); %Docstring -Emitted when attributes are deleted from the provider +Emitted when attributes are deleted from the provider if not in transaction mode. %End void committedAttributesAdded( const QString &layerId, const QList &addedAttributes ); %Docstring -Emitted when attributes are added to the provider +Emitted when attributes are added to the provider if not in transaction mode. %End void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures ); %Docstring -Emitted when features are added to the provider +Emitted when features are added to the provider if not in transaction mode. %End void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds ); %Docstring -Emitted when features are deleted from the provider +Emitted when features are deleted from the provider if not in transaction mode. %End void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues ); %Docstring -Emitted when attribute value changes are saved to the provider +Emitted when attribute value changes are saved to the provider if not in transaction mode. %End void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries ); %Docstring -Emitted when geometry changes are saved to the provider +Emitted when geometry changes are saved to the provider if not in transaction mode. %End void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily ); diff --git a/src/core/vector/qgsvectorlayer.h b/src/core/vector/qgsvectorlayer.h index 85c37cd9f7e..0e62feb99a4 100644 --- a/src/core/vector/qgsvectorlayer.h +++ b/src/core/vector/qgsvectorlayer.h @@ -2680,17 +2680,17 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte */ void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry ); - //! Emitted when attributes are deleted from the provider + //! Emitted when attributes are deleted from the provider if not in transaction mode. void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes ); - //! Emitted when attributes are added to the provider + //! Emitted when attributes are added to the provider if not in transaction mode. void committedAttributesAdded( const QString &layerId, const QList &addedAttributes ); - //! Emitted when features are added to the provider + //! Emitted when features are added to the provider if not in transaction mode. void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures ); - //! Emitted when features are deleted from the provider + //! Emitted when features are deleted from the provider if not in transaction mode. void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds ); - //! Emitted when attribute value changes are saved to the provider + //! Emitted when attribute value changes are saved to the provider if not in transaction mode. void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues ); - //! Emitted when geometry changes are saved to the provider + //! Emitted when geometry changes are saved to the provider if not in transaction mode. void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries ); //! Emitted when the font family defined for labeling layer is not found on system