Skip to content
Permalink
Browse files
[OGR provider] Run addFeatures() and deleteFeatures() within transaction
Cherry-picked from fbb8ffc
  • Loading branch information
rouault committed Mar 20, 2017
1 parent 6715441 commit 6becea740be58f6eac443f4d42121c8c29c27453
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/providers/ogr/qgsogrprovider.cpp
@@ -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 )
{
@@ -1315,6 +1317,11 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )
}
}

if ( inTransaction )
{
commitTransaction();
}

if ( !syncToDisc() )
{
returnvalue = false;
@@ -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 )
{
@@ -1829,6 +1838,11 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds & id )
}
}

if ( inTransaction )
{
commitTransaction();
}

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

0 comments on commit 6becea7

Please sign in to comment.