Fix updates of undo widget in styling panel

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)
This commit is contained in:
Martin Dobias 2016-07-06 22:27:17 +02:00
parent 1c91ae7733
commit 3e183a27d5
3 changed files with 14 additions and 22 deletions

View File

@ -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();
}
}
/**

View File

@ -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"
@ -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 );
@ -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 )

View File

@ -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