Skip to content
Permalink
Browse files

fixing bug #7822

  • Loading branch information
Daniel Vaz
Daniel Vaz committed Jun 28, 2013
1 parent 5e760dd commit 9a0be04113bcb673eeba5febd54cf4af860c36a5
Showing with 21 additions and 0 deletions.
  1. +18 −0 src/core/qgsvectorfilewriter.cpp
  2. +3 −0 src/core/qgsvectorfilewriter.h
@@ -801,6 +801,16 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,

writer->startRender( layer );

// enabling transaction on databases that support it
bool transactionsEnabled = true;
OGRLayerH ogrCurrentLayer = writer->getLayer();

if ( OGRERR_NONE != OGR_L_StartTransaction(ogrCurrentLayer) )
{
QgsDebugMsg("Error when trying to enable transactions on OGRLayer.");
transactionsEnabled = false;
}

// write all features
while ( fit.nextFeature( fet ) )
{
@@ -862,6 +872,14 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
n++;
}

if ( transactionsEnabled )
{
if ( OGRERR_NONE != OGR_L_CommitTransaction(ogrCurrentLayer) )
{
QgsDebugMsg("Error while commiting transaction on OGRLayer.");
}
}

writer->stopRender( layer );
delete writer;

@@ -154,6 +154,9 @@ class CORE_EXPORT QgsVectorFileWriter

double symbologyScaleDenominator() const { return mSymbologyScaleDenominator; }
void setSymbologyScaleDenominator( double d ) { mSymbologyScaleDenominator = d; }

/**Returns OGRLayer used to begin and commit transactions on database*/
OGRLayerH getLayer() { return mLayer; }

protected:
//! @note not available in python bindings

0 comments on commit 9a0be04

Please sign in to comment.
You can’t perform that action at this time.