Skip to content

Commit

Permalink
[postgres] do not update feature count if it was not set before
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and m-kuhn committed Sep 3, 2013
1 parent 510f5cb commit 70841a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/providers/postgres/qgspostgresfeatureiterator.cpp
Expand Up @@ -132,7 +132,11 @@ bool QgsPostgresFeatureIterator::nextFeature( QgsFeature& feature )
QgsDebugMsg( QString( "Finished after %1 features" ).arg( mFetched ) );
close();

if ( P->mFeaturesCounted < mFetched )
/* only updates the feature count if it was already once.
* Otherwise, this would lead to false feature count if
* an existing project is open at a restrictive extent.
*/
if ( P->mFeaturesCounted > 0 && P->mFeaturesCounted < mFetched )
{
QgsDebugMsg( QString( "feature count adjusted from %1 to %2" ).arg( P->mFeaturesCounted ).arg( mFetched ) );
P->mFeaturesCounted = mFetched;
Expand Down
7 changes: 4 additions & 3 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -1779,7 +1779,8 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
mConnectionRW->PQexecNR( "DEALLOCATE addfeatures" );
mConnectionRW->PQexecNR( "COMMIT" );

mFeaturesCounted += flist.size();
if ( mFeaturesCounted >= 0 )
mFeaturesCounted += flist.size();
}
catch ( PGException &e )
{
Expand Down Expand Up @@ -1835,8 +1836,8 @@ bool QgsPostgresProvider::deleteFeatures( const QgsFeatureIds & id )
dropOrphanedTopoGeoms();
}


mFeaturesCounted -= id.size();
if ( mFeaturesCounted >= 0 )
mFeaturesCounted -= id.size();
}
catch ( PGException &e )
{
Expand Down

0 comments on commit 70841a8

Please sign in to comment.