1717#include " qgsundowidget.h"
1818#include " qgsrendererv2.h"
1919#include " qgsrendererv2registry.h"
20+ #include " qgsmaplayerregistry.h"
2021
2122QgsMapStylingWidget::QgsMapStylingWidget ( QgsMapCanvas* canvas, QWidget *parent )
2223 : QWidget( parent )
@@ -29,6 +30,8 @@ QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QWidget *parent
2930 layout->setContentsMargins ( 0 , 0 , 0 , 0 );
3031 this ->setLayout ( layout );
3132
33+ connect ( QgsMapLayerRegistry::instance (), SIGNAL ( layerWillBeRemoved ( QgsMapLayer* ) ), this , SLOT ( layerAboutToBeRemoved ( QgsMapLayer* ) ) );
34+
3235 mAutoApplyTimer = new QTimer ( this );
3336 mAutoApplyTimer ->setSingleShot ( true );
3437 connect ( mAutoApplyTimer , SIGNAL ( timeout () ), this , SLOT ( apply () ) );
@@ -199,6 +202,16 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer( int currentPage )
199202 mBlockAutoApply = false ;
200203}
201204
205+ void QgsMapStylingWidget::layerAboutToBeRemoved ( QgsMapLayer* layer )
206+ {
207+ if ( layer == mCurrentLayer )
208+ {
209+ mAutoApplyTimer ->stop ();
210+ mStackedWidget ->setCurrentIndex ( mNotSupportedPage );
211+ mCurrentLayer = nullptr ;
212+ }
213+ }
214+
202215
203216QgsMapLayerStyleCommand::QgsMapLayerStyleCommand ( QgsMapLayer *layer, const QDomNode ¤t, const QDomNode &last )
204217 : QUndoCommand()
0 commit comments