diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index 8154c2ee031..01072f8a937 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -2438,6 +2438,9 @@ bool QgsVectorLayer::deleteFeature( QgsFeatureId fid ) if ( !mEditBuffer ) return false; + if ( mJoinBuffer->containsJoins() ) + deleteFeaturesFromJoinedLayers( QgsFeatureIds() << fid ); + bool res = mEditBuffer->deleteFeature( fid ); if ( res ) { @@ -2456,6 +2459,9 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids ) return false; } + if ( mJoinBuffer->containsJoins() ) + deleteFeaturesFromJoinedLayers( fids ); + bool res = mEditBuffer->deleteFeatures( fids ); if ( res ) @@ -2467,6 +2473,26 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids ) return res; } +bool QgsVectorLayer::deleteFeaturesFromJoinedLayers( QgsFeatureIds fids ) +{ + bool rc = false; + + Q_FOREACH ( const QgsFeatureId &fid, fids ) + { + Q_FOREACH ( const QgsVectorLayerJoinInfo &info, vectorJoins() ) + { + if ( info.isEditable() && info.isDeleteCascade() ) + { + QgsFeature joinFeature = mJoinBuffer->joinedFeatureOf( &info, getFeature( fid ) ); + if ( joinFeature.isValid() ) + info.joinLayer()->deleteFeature( joinFeature.id() ); + } + } + } + + return rc; +} + QgsAttributeList QgsVectorLayer::pkAttributeList() const { QgsAttributeList pkAttributesList; diff --git a/src/core/qgsvectorlayer.h b/src/core/qgsvectorlayer.h index d3fbece1932..28fdc70b64d 100644 --- a/src/core/qgsvectorlayer.h +++ b/src/core/qgsvectorlayer.h @@ -1933,6 +1933,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties(); bool addFeaturesToJoinedLayers( QgsFeatureList &features, Flags flags = 0 ); + bool deleteFeaturesFromJoinedLayers( QgsFeatureIds fids ); #ifdef SIP_RUN QgsVectorLayer( const QgsVectorLayer &rhs );