Skip to content

Commit

Permalink
Update vector layer edits rollback method and app rollback actions
Browse files Browse the repository at this point in the history
- 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 8feb84a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -3326,7 +3326,7 @@ const QStringList &QgsVectorLayer::commitErrors()
return mCommitErrors;
}

bool QgsVectorLayer::rollBack()
bool QgsVectorLayer::rollBack( bool deleteBuffer )
{
if ( !mEditBuffer )
{
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/core/qgsvectorlayer.h
Expand Up @@ -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 );
Expand Down

0 comments on commit 8feb84a

Please sign in to comment.