Skip to content

Commit

Permalink
Fix updates of undo widget in styling panel
Browse files Browse the repository at this point in the history
Before, on current layer change it would switch to undo stack
of freshly activated layer, ignoring the layer set in the combo box
(and the undo stack it switched to was the one for editing)
  • Loading branch information
wonder-sk committed Jul 6, 2016
1 parent 1c91ae7 commit 3e183a2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
13 changes: 13 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,19 @@ void QgisApp::activeLayerChanged( QgsMapLayer* layer )
{
if ( mMapCanvas )
mMapCanvas->setCurrentLayer( layer );

if ( mUndoWidget )
{
if ( layer )
{
mUndoWidget->setUndoStack( layer->undoStack() );
}
else
{
mUndoWidget->destroyStack();
}
updateUndoActions();
}
}

/**
Expand Down
19 changes: 1 addition & 18 deletions src/app/qgsundowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
***************************************************************************/
#include "qgsundowidget.h"

#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgslayertreeview.h"
#include "qgslogger.h"
#include "qgsmaplayer.h"
#include "qgsmapcanvas.h"

Expand All @@ -28,8 +27,6 @@ QgsUndoWidget::QgsUndoWidget( QWidget * parent, QgsMapCanvas * mapCanvas )

connect( undoButton, SIGNAL( clicked() ), this, SLOT( undo() ) );
connect( redoButton, SIGNAL( clicked() ), this, SLOT( redo() ) );
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
this, SLOT( layerChanged( QgsMapLayer* ) ) );

undoButton->setDisabled( true );
redoButton->setDisabled( true );
Expand All @@ -42,20 +39,6 @@ QgsUndoWidget::QgsUndoWidget( QWidget * parent, QgsMapCanvas * mapCanvas )
}


void QgsUndoWidget::layerChanged( QgsMapLayer * layer )
{
if ( layer )
{
setUndoStack( layer->undoStack() );
}
else
{
destroyStack();
}
emit undoStackChanged();
}


void QgsUndoWidget::destroyStack()
{
if ( mUndoStack )
Expand Down
4 changes: 0 additions & 4 deletions src/app/qgsundowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ class APP_EXPORT QgsUndoWidget : public QgsPanelWidget
QWidget* dockContents() { return dockWidgetContents; }

public slots:
/**
* Changes undo stack which is displayed by undo view
*/
void layerChanged( QgsMapLayer * layer );

/**
* Slot to handle undo changed signal
Expand Down

0 comments on commit 3e183a2

Please sign in to comment.