@@ -65,13 +65,6 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ):
65
65
pluginNameQString = tr ( " GrassVector" );
66
66
pluginVersionQString = tr ( " 0.1" );
67
67
pluginDescriptionQString = tr ( " GRASS layer" );
68
- QString gisdbase = QgsGrass::getDefaultGisdbase ();
69
- QString location = QgsGrass::getDefaultLocation ();
70
- mCanvas = qGisInterface->mapCanvas ();
71
- mCrs = QgsGrass::crs ( gisdbase, location );
72
- QgsDebugMsg ( " mCrs: " + mCrs .toWkt () );
73
- setTransform ();
74
- connect ( qGisInterface->mapCanvas ()->mapRenderer (), SIGNAL ( destinationSrsChanged () ), this , SLOT ( setTransform () ) );
75
68
}
76
69
77
70
QgsGrassPlugin::~QgsGrassPlugin ()
@@ -118,9 +111,8 @@ void QgsGrassPlugin::initGui()
118
111
mRegion = 0 ;
119
112
120
113
QSettings settings;
121
-
122
114
QgsGrass::init ();
123
-
115
+ mCanvas = qGisInterface-> mapCanvas ();
124
116
QWidget* qgis = qGisInterface->mainWindow ();
125
117
126
118
// Connect project
@@ -598,6 +590,15 @@ void QgsGrassPlugin::displayRegion()
598
590
599
591
QgsGrass::setLocation ( gisdbase, location );
600
592
593
+ // TODO: check better if we have to init + maybe the location can change -> mCrs must be reloaded
594
+ if ( !mCrs .isValid () )
595
+ {
596
+ mCrs = QgsGrass::crs ( gisdbase, location );
597
+ QgsDebugMsg ( " mCrs: " + mCrs .toWkt () );
598
+ setTransform ();
599
+ connect ( mCanvas ->mapRenderer (), SIGNAL ( destinationSrsChanged () ), this , SLOT ( setTransform () ) );
600
+ }
601
+
601
602
struct Cell_head window;
602
603
char *err = G__get_window ( &window, ( char * ) " " , ( char * ) " WIND" , mapset.toLatin1 ().data () );
603
604
0 commit comments