Skip to content
Permalink
Browse files

Merge pull request #5414 from m-kuhn/transactionStack

Deal with failure to create savepoint
  • Loading branch information
pblottiere committed Nov 3, 2017
2 parents c177995 + 479970b commit 67b1cab3a1128ad9a1e665d4608e989025a96ca7
Showing with 9 additions and 1 deletion.
  1. +7 −0 src/core/qgstransaction.cpp
  2. +2 −1 src/core/qgsvectorlayerundopassthroughcommand.cpp
@@ -24,6 +24,7 @@
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgsexpression.h"
#include "qgsmessagelog.h"
#include <QUuid>

typedef QgsTransaction *createTransaction_t( const QString &connString );
@@ -195,7 +196,10 @@ QString QgsTransaction::createSavepoint( QString &error SIP_OUT )
const QString name( QUuid::createUuid().toString() );

if ( !executeSql( QStringLiteral( "SAVEPOINT %1" ).arg( QgsExpression::quotedColumnRef( name ) ), error ) )
{
QgsMessageLog::logMessage( tr( "Could not create savepoint (%1)" ).arg( error ) );
return QString();
}

mSavepoints.push( name );
mLastSavePointIsDirty = false;
@@ -208,7 +212,10 @@ QString QgsTransaction::createSavepoint( const QString &savePointId, QString &er
return QString();

if ( !executeSql( QStringLiteral( "SAVEPOINT %1" ).arg( QgsExpression::quotedColumnRef( savePointId ) ), error ) )
{
QgsMessageLog::logMessage( tr( "Could not create savepoint (%1)" ).arg( error ) );
return QString();
}

mSavepoints.push( savePointId );
mLastSavePointIsDirty = false;
@@ -31,7 +31,8 @@

QgsVectorLayerUndoPassthroughCommand::QgsVectorLayerUndoPassthroughCommand( QgsVectorLayerEditBuffer *buffer, const QString &text, bool autocreate )
: QgsVectorLayerUndoCommand( buffer )
, mSavePointId( mBuffer->L->isEditCommandActive() || !autocreate
, mSavePointId( mBuffer->L->isEditCommandActive() && !mBuffer->L->dataProvider()->transaction()->savePoints().isEmpty()
|| !autocreate
? mBuffer->L->dataProvider()->transaction()->savePoints().last()
: mBuffer->L->dataProvider()->transaction()->createSavepoint( mError ) )
, mHasError( !mError.isEmpty() )

0 comments on commit 67b1cab

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