Skip to content

Commit 2de2f23

Browse files
committedFeb 11, 2013
Limit canvas redraws when working with vector layer undo stack
- Fix unreported bug where clicking on group in legend would clear previously selected vector layer's undo stack - Ensure empty view is created on project load (cosmetic)
1 parent 8feb84a commit 2de2f23

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed
 

‎src/app/qgsundowidget.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ void QgsUndoWidget::destroyStack()
6161
{
6262
if ( mUndoStack != NULL )
6363
{
64-
mUndoStack->clear();
64+
// do not clear undo stack here, just null pointer
6565
mUndoStack = NULL;
6666
}
6767
if ( mUndoView != NULL )
6868
{
6969
mUndoView->close();
70-
mUndoView = NULL;
70+
delete mUndoView;
71+
mUndoView = new QUndoView( dockWidgetContents );
72+
gridLayout->addWidget( mUndoView, 0, 0, 1, 2 );
7173
}
7274
}
7375

@@ -99,23 +101,24 @@ void QgsUndoWidget::indexChanged( int curIndx )
99101
// when individually redoing, differentiate between last redo and a new command added to stack
100102
bool lastRedo = ( mPreviousIndex == ( mPreviousCount - 1 ) && mPreviousCount == curCount && !canRedo );
101103

102-
bool debugThis = false;
103-
if ( debugThis && offset != 0 )
104+
if ( offset != 0 )
104105
{
105-
// '= Rendering =' text is for filtering log results to also only show canvas rendering event
106-
QgsDebugMsg( QString( "= Rendering = curIndx : %1" ).arg( curIndx ) );
107-
QgsDebugMsg( QString( "= Rendering = offset : %1" ).arg( offset ) );
108-
QgsDebugMsg( QString( "= Rendering = curCount: %1" ).arg( curCount ) );
106+
QgsDebugMsg( QString( "curIndx : %1" ).arg( curIndx ) );
107+
QgsDebugMsg( QString( "offset : %1" ).arg( offset ) );
108+
QgsDebugMsg( QString( "curCount: %1" ).arg( curCount ) );
109109
if ( lastRedo )
110-
QgsDebugMsg( QString( "= Rendering = lastRedo: true" ) );
110+
QgsDebugMsg( QString( "lastRedo: true" ) );
111111
}
112112

113-
// avoid canvas refresh when only a command was added to stack (i.e. no user undo/redo action)
114-
// or when user has clicked back in view history then added a new command to the stack
113+
// avoid canvas redraws when only new command was added to stack (i.e. no user undo/redo action)
114+
// or when user has clicked back in QUndoView history then added a new command to the stack
115115
if ( offset > 1 || ( offset == 1 && ( canRedo || lastRedo ) ) )
116116
{
117117
if ( mMapCanvas )
118+
{
119+
QgsDebugMsg( QString( "trigger redraw" ) );
118120
mMapCanvas->refresh();
121+
}
119122
}
120123

121124
mPreviousIndex = curIndx;

‎src/core/qgsvectorlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ bool QgsVectorLayer::startEditing()
22282228
mEditBuffer = new QgsVectorLayerEditBuffer( this );
22292229
// forward signals
22302230
connect( mEditBuffer, SIGNAL( layerModified() ), this, SIGNAL( layerModified() ) ); // TODO[MD]: necessary?
2231-
connect( mEditBuffer, SIGNAL( layerModified() ), this, SLOT( triggerRepaint() ) ); // TODO[MD]: works well?
2231+
//connect( mEditBuffer, SIGNAL( layerModified() ), this, SLOT( triggerRepaint() ) ); // TODO[MD]: works well?
22322232
connect( mEditBuffer, SIGNAL( featureAdded( QgsFeatureId ) ), this, SIGNAL( featureAdded( QgsFeatureId ) ) );
22332233
connect( mEditBuffer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SIGNAL( featureDeleted( QgsFeatureId ) ) );
22342234
connect( mEditBuffer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry& ) ), this, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry& ) ) );

‎src/core/qgsvectorlayereditbuffer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,9 @@ void QgsVectorLayerEditBuffer::rollBack()
445445
if ( !isModified() )
446446
return;
447447

448-
while ( L->undoStack()->canUndo() )
449-
{
450-
L->undoStack()->undo();
451-
}
448+
// limit canvas redraws to one by jumping to beginning of stack
449+
// see QgsUndoWidget::indexChanged
450+
L->undoStack()->setIndex( 0 );
452451

453452
Q_ASSERT( mAddedAttributes.isEmpty() );
454453
Q_ASSERT( mDeletedAttributeIds.isEmpty() );

0 commit comments

Comments
 (0)
Please sign in to comment.