Skip to content

Commit

Permalink
[OGR provider] Run addFeatures() and deleteFeatures() within transaction
Browse files Browse the repository at this point in the history
Cherry-picked from fbb8ffc
  • Loading branch information
rouault committed Mar 20, 2017
1 parent 6715441 commit 6becea7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1306,6 +1306,8 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )

setRelevantFields( ogrLayer, true, attributeIndexes() );

const bool inTransaction = startTransaction();

bool returnvalue = true;
for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
{
Expand All @@ -1315,6 +1317,11 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )
}
}

if ( inTransaction )
{
commitTransaction();
}

if ( !syncToDisc() )
{
returnvalue = false;
Expand Down Expand Up @@ -1820,6 +1827,8 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds & id )
if ( !doInitialActionsForEdition() )
return false;

const bool inTransaction = startTransaction();

bool returnvalue = true;
for ( QgsFeatureIds::const_iterator it = id.begin(); it != id.end(); ++it )
{
Expand All @@ -1829,6 +1838,11 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds & id )
}
}

if ( inTransaction )
{
commitTransaction();
}

if ( !syncToDisc() )
{
returnvalue = false;
Expand Down

0 comments on commit 6becea7

Please sign in to comment.