Skip to content

Commit

Permalink
[OGR provider] Run addFeatures() and deleteFeatures() within transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault authored and m-kuhn committed Mar 15, 2017
1 parent 16a421c commit fbb8ffc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1319,6 +1319,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 @@ -1328,6 +1330,11 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList &flist )
}
}

if ( inTransaction )
{
commitTransaction();
}

if ( !syncToDisc() )
{
returnvalue = false;
Expand Down Expand Up @@ -1818,6 +1825,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 @@ -1827,6 +1836,11 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds &id )
}
}

if ( inTransaction )
{
commitTransaction();
}

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

0 comments on commit fbb8ffc

Please sign in to comment.