@@ -102,7 +102,6 @@ QgsGrassPlugin::~QgsGrassPlugin()
102
102
// -> do not call mTools here
103
103
// if ( mTools )
104
104
// mTools->closeTools();
105
- disconnect ( QgsGrass::instance (), SIGNAL ( mapsetChanged () ), this , SLOT ( mapsetChanged () ) );
106
105
QgsGrass::instance ()->closeMapsetWarn ();
107
106
}
108
107
@@ -147,13 +146,6 @@ void QgsGrassPlugin::initGui()
147
146
mNewMapset = 0 ;
148
147
149
148
mCanvas = qGisInterface->mapCanvas ();
150
- QWidget* qgis = qGisInterface->mainWindow ();
151
-
152
- connect ( mCanvas , SIGNAL ( destinationCrsChanged () ), this , SLOT ( setTransform () ) );
153
-
154
- // Connect project
155
- connect ( qgis, SIGNAL ( projectRead () ), this , SLOT ( projectRead () ) );
156
- connect ( qgis, SIGNAL ( newProject () ), this , SLOT ( newProject () ) );
157
149
158
150
// Create region rubber band
159
151
mRegionBand = new QgsRubberBand ( mCanvas , QGis::Polygon );
@@ -179,12 +171,12 @@ void QgsGrassPlugin::initGui()
179
171
mOptionsAction = new QAction ( QIcon (), tr ( " GRASS Options" ), this );
180
172
mOptionsAction ->setObjectName ( " mOptionsAction" );
181
173
182
- // Connect the action
183
- connect ( mOpenToolsAction , SIGNAL ( triggered () ), this , SLOT ( openTools () ) );
184
- connect ( mRegionAction , SIGNAL ( toggled ( bool ) ), this , SLOT ( switchRegion ( bool ) ) );
174
+ // Connect the actions
185
175
connect ( mOpenMapsetAction , SIGNAL ( triggered () ), this , SLOT ( openMapset () ) );
186
176
connect ( mNewMapsetAction , SIGNAL ( triggered () ), this , SLOT ( newMapset () ) );
187
177
connect ( mCloseMapsetAction , SIGNAL ( triggered () ), SLOT ( closeMapset () ) );
178
+ connect ( mOpenToolsAction , SIGNAL ( triggered () ), this , SLOT ( openTools () ) );
179
+ connect ( mRegionAction , SIGNAL ( toggled ( bool ) ), this , SLOT ( switchRegion ( bool ) ) );
188
180
connect ( mOptionsAction , SIGNAL ( triggered () ), QgsGrass::instance (), SLOT ( openOptions () ) );
189
181
190
182
// Add actions to a GRASS plugin menu
@@ -262,11 +254,18 @@ void QgsGrassPlugin::initGui()
262
254
mAddArea = new QgsGrassAddFeature ( qGisInterface->mapCanvas (), QgsMapToolAdvancedDigitizing::CapturePolygon );
263
255
mAddArea ->setAction ( mAddAreaAction );
264
256
257
+ // Connect project
258
+ QWidget* qgis = qGisInterface->mainWindow ();
259
+ connect ( qgis, SIGNAL ( projectRead () ), this , SLOT ( projectRead () ) );
260
+ connect ( qgis, SIGNAL ( newProject () ), this , SLOT ( newProject () ) );
261
+
265
262
// Set icons to current theme
266
263
setCurrentTheme ( " " );
267
264
// Connect theme change signal
268
265
connect ( qGisInterface, SIGNAL ( currentThemeChanged ( QString ) ), this , SLOT ( setCurrentTheme ( QString ) ) );
269
266
267
+ connect ( mCanvas , SIGNAL ( destinationCrsChanged () ), this , SLOT ( setTransform () ) );
268
+
270
269
// Connect display region
271
270
connect ( mCanvas , SIGNAL ( renderComplete ( QPainter * ) ), this , SLOT ( postRender ( QPainter * ) ) );
272
271
@@ -522,14 +521,6 @@ void QgsGrassPlugin::mapsetChanged()
522
521
// Open tools
523
522
void QgsGrassPlugin::openTools ()
524
523
{
525
- #if 0
526
- if ( !mTools )
527
- {
528
- mTools = new QgsGrassTools( qGisInterface, qGisInterface->mainWindow(), 0, Qt::Dialog );
529
-
530
- connect( mTools, SIGNAL( regionChanged() ), this, SLOT( redrawRegion() ) );
531
- }
532
- #endif
533
524
mTools ->show ();
534
525
}
535
526
@@ -766,6 +757,40 @@ void QgsGrassPlugin::unload()
766
757
// Close mapset
767
758
QgsGrass::instance ()->closeMapsetWarn ();
768
759
760
+ // disconnect slots of QgsGrassPlugin so they're not fired also after unload
761
+ QWidget* qgis = qGisInterface->mainWindow ();
762
+ disconnect ( qgis, SIGNAL ( projectRead () ), this , SLOT ( projectRead () ) );
763
+ disconnect ( qgis, SIGNAL ( newProject () ), this , SLOT ( newProject () ) );
764
+ disconnect ( qGisInterface, SIGNAL ( currentThemeChanged ( QString ) ), this , SLOT ( setCurrentTheme ( QString ) ) );
765
+ disconnect ( mCanvas , SIGNAL ( destinationCrsChanged () ), this , SLOT ( setTransform () ) );
766
+ disconnect ( mCanvas , SIGNAL ( renderComplete ( QPainter * ) ), this , SLOT ( postRender ( QPainter * ) ) );
767
+
768
+ disconnect ( QgsGrass::instance (), SIGNAL ( gisbaseChanged () ), this , SLOT ( onGisbaseChanged () ) );
769
+ disconnect ( QgsGrass::instance (), SIGNAL ( mapsetChanged () ), this , SLOT ( mapsetChanged () ) );
770
+ disconnect ( QgsGrass::instance (), SIGNAL ( regionChanged () ), this , SLOT ( displayRegion () ) );
771
+ disconnect ( QgsGrass::instance (), SIGNAL ( regionPenChanged () ), this , SLOT ( displayRegion () ) );
772
+ disconnect ( QgsGrass::instance (), SIGNAL ( newLayer ( QString, QString ) ), this , SLOT ( onNewLayer ( QString, QString ) ) );
773
+
774
+ disconnect ( QgsMapLayerRegistry::instance (), SIGNAL ( layerWasAdded ( QgsMapLayer* ) ), this , SLOT ( onLayerWasAdded ( QgsMapLayer* ) ) );
775
+
776
+ disconnect ( qGisInterface->layerTreeView (), SIGNAL ( currentLayerChanged ( QgsMapLayer* ) ),
777
+ this , SLOT ( onCurrentLayerChanged ( QgsMapLayer* ) ) );
778
+
779
+ foreach ( QgsMapLayer *layer, QgsMapLayerRegistry::instance ()->mapLayers ().values () )
780
+ {
781
+ if ( !layer || layer->type () != QgsMapLayer::VectorLayer )
782
+ {
783
+ continue ;
784
+ }
785
+
786
+ QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( layer );
787
+ if ( vectorLayer && vectorLayer->providerType () == " grass" )
788
+ {
789
+ disconnect ( vectorLayer, SIGNAL ( editingStarted () ), this , SLOT ( onEditingStarted () ) );
790
+ disconnect ( vectorLayer, SIGNAL ( editingStopped () ), this , SLOT ( onEditingStopped () ) );
791
+ }
792
+ }
793
+
769
794
// remove the GUI
770
795
qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mOpenMapsetAction );
771
796
qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mNewMapsetAction );
@@ -781,7 +806,6 @@ void QgsGrassPlugin::unload()
781
806
delete mRegionAction ;
782
807
delete mOptionsAction ;
783
808
784
- delete mAddFeatureAction ;
785
809
delete mAddPointAction ;
786
810
delete mAddLineAction ;
787
811
delete mAddBoundaryAction ;
@@ -797,13 +821,6 @@ void QgsGrassPlugin::unload()
797
821
delete mToolBarPointer ;
798
822
mToolBarPointer = 0 ;
799
823
800
- // disconnect slots of QgsGrassPlugin so they're not fired also after unload
801
- disconnect ( mCanvas , SIGNAL ( renderComplete ( QPainter * ) ), this , SLOT ( postRender ( QPainter * ) ) );
802
-
803
- QWidget* qgis = qGisInterface->mainWindow ();
804
- disconnect ( qgis, SIGNAL ( projectRead () ), this , SLOT ( projectRead () ) );
805
- disconnect ( qgis, SIGNAL ( newProject () ), this , SLOT ( newProject () ) );
806
-
807
824
delete mTools ;
808
825
mTools = 0 ;
809
826
}
0 commit comments