Skip to content

Commit

Permalink
Merge pull request #5414 from m-kuhn/transactionStack
Browse files Browse the repository at this point in the history
Deal with failure to create savepoint
  • Loading branch information
pblottiere committed Nov 3, 2017
2 parents c177995 + 479970b commit 67b1cab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/core/qgstransaction.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsvectorlayerundopassthroughcommand.cpp
Expand Up @@ -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() )
Expand Down

0 comments on commit 67b1cab

Please sign in to comment.