Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid crash in style dock when layer is removed
  • Loading branch information
nyalldawson committed May 18, 2016
1 parent 46fb193 commit 5dd88c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/qgsmapstylingwidget.cpp
Expand Up @@ -17,6 +17,7 @@
#include "qgsundowidget.h"
#include "qgsrendererv2.h"
#include "qgsrendererv2registry.h"
#include "qgsmaplayerregistry.h"

QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QWidget *parent )
: QWidget( parent )
Expand All @@ -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() ) );
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsmapstylingwidget.h
Expand Up @@ -49,6 +49,7 @@ class APP_EXPORT QgsMapStylingWidget : public QWidget

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

private:
int mNotSupportedPage;
Expand Down

1 comment on commit 5dd88c9

@NathanW2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Please sign in to comment.