Skip to content

Commit

Permalink
Fix iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 1, 2021
1 parent 1e3b545 commit 731fd33
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -2657,8 +2657,10 @@ bool QgsPostgresProvider::deleteFeatures( const QgsFeatureIds &ids )
conn->begin();

QgsFeatureIds chunkIds;
const QgsFeatureIds::const_iterator lastId = --ids.end();
for ( QgsFeatureIds::const_iterator it = ids.begin(); it != ids.end(); ++it )
QgsFeatureIds::const_iterator lastId = ids.constEnd();
lastId--;

for ( QgsFeatureIds::const_iterator it = ids.constBegin(); it != ids.constEnd(); ++it )
{
// create chunks of fids to delete, the last chunk may be smaller
chunkIds.insert( *it );
Expand All @@ -2674,7 +2676,7 @@ bool QgsPostgresProvider::deleteFeatures( const QgsFeatureIds &ids )
if ( result.PQresultStatus() != PGRES_COMMAND_OK && result.PQresultStatus() != PGRES_TUPLES_OK )
throw PGException( result );

for ( QgsFeatureIds::const_iterator chunkIt = chunkIds.begin(); chunkIt != chunkIds.end(); ++chunkIt )
for ( QgsFeatureIds::const_iterator chunkIt = chunkIds.constBegin(); chunkIt != chunkIds.constEnd(); ++chunkIt )
{
mShared->removeFid( *chunkIt );
}
Expand Down

0 comments on commit 731fd33

Please sign in to comment.