Skip to content
Permalink
Browse files

Avoid crash in style dock when layer is removed

  • Loading branch information
nyalldawson committed May 18, 2016
1 parent 46fb193 commit 5dd88c990b8dfb8e89f944a4d139deca027dfc97
Showing with 14 additions and 0 deletions.
  1. +13 −0 src/app/qgsmapstylingwidget.cpp
  2. +1 −0 src/app/qgsmapstylingwidget.h
@@ -17,6 +17,7 @@
#include "qgsundowidget.h"
#include "qgsrendererv2.h"
#include "qgsrendererv2registry.h"
#include "qgsmaplayerregistry.h"

QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QWidget *parent )
: QWidget( parent )
@@ -29,6 +30,8 @@ QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QWidget *parent
layout->setContentsMargins( 0, 0, 0, 0 );
this->setLayout( layout );

connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QgsMapLayer* ) ), this, SLOT( layerAboutToBeRemoved( QgsMapLayer* ) ) );

mAutoApplyTimer = new QTimer( this );
mAutoApplyTimer->setSingleShot( true );
connect( mAutoApplyTimer, SIGNAL( timeout() ), this, SLOT( apply() ) );
@@ -199,6 +202,16 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer( int currentPage )
mBlockAutoApply = false;
}

void QgsMapStylingWidget::layerAboutToBeRemoved( QgsMapLayer* layer )
{
if ( layer == mCurrentLayer )
{
mAutoApplyTimer->stop();
mStackedWidget->setCurrentIndex( mNotSupportedPage );
mCurrentLayer = nullptr;
}
}


QgsMapLayerStyleCommand::QgsMapLayerStyleCommand( QgsMapLayer *layer, const QDomNode &current, const QDomNode &last )
: QUndoCommand()
@@ -49,6 +49,7 @@ class APP_EXPORT QgsMapStylingWidget : public QWidget

private slots:
void updateCurrentWidgetLayer( int currentPage );
void layerAboutToBeRemoved( QgsMapLayer* layer );

private:
int mNotSupportedPage;

1 comment on commit 5dd88c9

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 commented on 5dd88c9 May 18, 2016

Thanks.

Please sign in to comment.
You can’t perform that action at this time.