17
17
#include " qgsundowidget.h"
18
18
#include " qgsrendererv2.h"
19
19
#include " qgsrendererv2registry.h"
20
+ #include " qgsmaplayerregistry.h"
20
21
21
22
QgsMapStylingWidget::QgsMapStylingWidget ( QgsMapCanvas* canvas, QWidget *parent )
22
23
: QWidget( parent )
@@ -29,6 +30,8 @@ QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QWidget *parent
29
30
layout->setContentsMargins ( 0 , 0 , 0 , 0 );
30
31
this ->setLayout ( layout );
31
32
33
+ connect ( QgsMapLayerRegistry::instance (), SIGNAL ( layerWillBeRemoved ( QgsMapLayer* ) ), this , SLOT ( layerAboutToBeRemoved ( QgsMapLayer* ) ) );
34
+
32
35
mAutoApplyTimer = new QTimer ( this );
33
36
mAutoApplyTimer ->setSingleShot ( true );
34
37
connect ( mAutoApplyTimer , SIGNAL ( timeout () ), this , SLOT ( apply () ) );
@@ -199,6 +202,16 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer( int currentPage )
199
202
mBlockAutoApply = false ;
200
203
}
201
204
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
+
202
215
203
216
QgsMapLayerStyleCommand::QgsMapLayerStyleCommand ( QgsMapLayer *layer, const QDomNode ¤t, const QDomNode &last )
204
217
: QUndoCommand()
0 commit comments