Skip to content
Permalink
Browse files
Update vector layer edits rollback method and app rollback actions
- Make optional whether edit buffer is deleted
- Returns optional functionality where rollback was similar to setting undo stack to index 0
  • Loading branch information
dakcarto committed Feb 11, 2013
1 parent ba2082e commit 8feb84af4605678957f4eb8d61e03c3d1622df80
Showing with 12 additions and 6 deletions.
  1. +1 −1 src/app/qgisapp.cpp
  2. +7 −3 src/core/qgsvectorlayer.cpp
  3. +4 −2 src/core/qgsvectorlayer.h
@@ -5449,7 +5449,7 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable, bool triggerR
mSaveRollbackInProgress = true;

mMapCanvas->freeze( true );
if ( !vlayer->rollBack() )
if ( !vlayer->rollBack( !leaveEditable ) )
{
mSaveRollbackInProgress = false;
QMessageBox::information( 0,
@@ -3326,7 +3326,7 @@ const QStringList &QgsVectorLayer::commitErrors()
return mCommitErrors;
}

bool QgsVectorLayer::rollBack()
bool QgsVectorLayer::rollBack( bool deleteBuffer )
{
if ( !mEditBuffer )
{
@@ -3344,8 +3344,12 @@ bool QgsVectorLayer::rollBack()

updateFields();

delete mEditBuffer;
mEditBuffer = 0;
if ( deleteBuffer )
{
delete mEditBuffer;
mEditBuffer = 0;
undoStack()->clear();
}
emit editingStopped();

// invalidate the cache so the layer updates properly to show its original
@@ -713,8 +713,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
bool commitChanges();
const QStringList &commitErrors();

/** Stop editing and discard the edits */
bool rollBack();
/** Stop editing and discard the edits
* @param deleteBuffer whether to delete editing buffer (added in 1.9)
*/
bool rollBack( bool deleteBuffer = true );

/**get edit type*/
EditType editType( int idx );

0 comments on commit 8feb84a

Please sign in to comment.