From 4cf40fb32f3c82a245a05ebbf94a9a1ce691322f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 17 Oct 2020 17:25:36 +0200 Subject: [PATCH] QgsOgrProvider::deleteFeatures(): restore previous (odd) behaviour regarding shapefiles and feature count --- src/core/providers/ogr/qgsogrprovider.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/providers/ogr/qgsogrprovider.cpp b/src/core/providers/ogr/qgsogrprovider.cpp index 549311aafc7a..822640579023 100644 --- a/src/core/providers/ogr/qgsogrprovider.cpp +++ b/src/core/providers/ogr/qgsogrprovider.cpp @@ -2709,13 +2709,21 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds &id ) returnvalue = false; } - if ( mFeaturesCounted != QgsVectorDataProvider::Uncounted && - mFeaturesCounted != QgsVectorDataProvider::UnknownCount ) + if ( mGDALDriverName == QLatin1String( "ESRI Shapefile" ) ) { - if ( returnvalue ) - mFeaturesCounted -= id.size(); - else - recalculateFeatureCount(); + // Shapefile behaves in a special way due to possible recompaction + recalculateFeatureCount(); + } + else + { + if ( mFeaturesCounted != QgsVectorDataProvider::Uncounted && + mFeaturesCounted != QgsVectorDataProvider::UnknownCount ) + { + if ( returnvalue ) + mFeaturesCounted -= id.size(); + else + recalculateFeatureCount(); + } } clearMinMaxCache();