Skip to content
Permalink
Browse files
[OGR provider] Run addFeatures() and deleteFeatures() within transaction
  • Loading branch information
rouault authored and m-kuhn committed Mar 15, 2017
1 parent 16a421c commit fbb8ffcc164828158bef551bfbfc1302e8f8145f
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/providers/ogr/qgsogrprovider.cpp
@@ -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 )
{
@@ -1328,6 +1330,11 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList &flist )
}
}

if ( inTransaction )
{
commitTransaction();
}

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

if ( inTransaction )
{
commitTransaction();
}

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

0 comments on commit fbb8ffc

Please sign in to comment.