Skip to content

Commit fbb8ffc

Browse files
rouaultm-kuhn
authored andcommitted
[OGR provider] Run addFeatures() and deleteFeatures() within transaction
1 parent 16a421c commit fbb8ffc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/providers/ogr/qgsogrprovider.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,8 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList &flist )
13191319

13201320
setRelevantFields( ogrLayer, true, attributeIndexes() );
13211321

1322+
const bool inTransaction = startTransaction();
1323+
13221324
bool returnvalue = true;
13231325
for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
13241326
{
@@ -1328,6 +1330,11 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList &flist )
13281330
}
13291331
}
13301332

1333+
if ( inTransaction )
1334+
{
1335+
commitTransaction();
1336+
}
1337+
13311338
if ( !syncToDisc() )
13321339
{
13331340
returnvalue = false;
@@ -1818,6 +1825,8 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds &id )
18181825
if ( !doInitialActionsForEdition() )
18191826
return false;
18201827

1828+
const bool inTransaction = startTransaction();
1829+
18211830
bool returnvalue = true;
18221831
for ( QgsFeatureIds::const_iterator it = id.begin(); it != id.end(); ++it )
18231832
{
@@ -1827,6 +1836,11 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds &id )
18271836
}
18281837
}
18291838

1839+
if ( inTransaction )
1840+
{
1841+
commitTransaction();
1842+
}
1843+
18301844
if ( !syncToDisc() )
18311845
{
18321846
returnvalue = false;

0 commit comments

Comments
 (0)