Skip to content
Permalink
Browse files

call deleteFeature in deleteFeatures, instead going through the loops…

… in QgsVectorLayerEditBuffer instead to have everything going the same way on the QgsVectorLayer level

and use of private deleteFeature function to avoid multiple remove of selected feature ids and multiple call of updateExtents()
  • Loading branch information
signedav committed May 7, 2020
1 parent 9e91eb5 commit 9cc2496d84d96ecde6e9c0ff3b0139bdf07f18d4
Showing with 18 additions and 11 deletions.
  1. +16 −11 src/core/qgsvectorlayer.cpp
  2. +2 −0 src/core/qgsvectorlayer.h
@@ -3164,7 +3164,7 @@ bool QgsVectorLayer::deleteAttributes( const QList<int> &attrs )
return deleted;
}

bool QgsVectorLayer::deleteFeature( QgsFeatureId fid )
bool QgsVectorLayer::deleteFeatureWithDependencies( QgsFeatureId fid )
{
if ( !mEditBuffer )
return false;
@@ -3173,6 +3173,17 @@ bool QgsVectorLayer::deleteFeature( QgsFeatureId fid )
mJoinBuffer->deleteFeature( fid );

bool res = mEditBuffer->deleteFeature( fid );

return res;
}

bool QgsVectorLayer::deleteFeature( QgsFeatureId fid )
{
if ( !mEditBuffer )
return false;

bool res = deleteFeatureWithDependencies( fid );

if ( res )
{
mSelectedFeatureIds.remove( fid ); // remove it from selection
@@ -3184,16 +3195,10 @@ bool QgsVectorLayer::deleteFeature( QgsFeatureId fid )

bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids )
{
if ( !mEditBuffer )
{
QgsDebugMsgLevel( QStringLiteral( "Cannot delete features (mEditBuffer==NULL)" ), 1 );
return false;
}

if ( mJoinBuffer->containsJoins() )
mJoinBuffer->deleteFeatures( fids );

bool res = mEditBuffer->deleteFeatures( fids );
bool res = true;
const auto constFids = fids;
for ( QgsFeatureId fid : constFids )
res = deleteFeatureWithDependencies( fid ) && res;

if ( res )
{
@@ -2689,6 +2689,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
//! Read simple labeling from layer's custom properties (QGIS 2.x projects)
QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();

bool deleteFeatureWithDependencies( QgsFeatureId fid );

#ifdef SIP_RUN
QgsVectorLayer( const QgsVectorLayer &rhs );
#endif

0 comments on commit 9cc2496

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