@@ -328,7 +328,7 @@ void QgsGrass::init( void )
328
328
#else
329
329
QString gisBase = getenv ( " GISBASE" );
330
330
#endif
331
- QgsDebugMsg ( QString ( " GRASS gisBase from GISBASE env var is: %1" ).arg ( gisBase ) );
331
+ QgsDebugMsg ( QString ( " GRASS gisBase from GISBASE/WINGISBASE env var is: %1" ).arg ( gisBase ) );
332
332
if ( !isValidGrassBaseDir ( gisBase ) )
333
333
{
334
334
// Look for gisbase in QSettings
@@ -381,7 +381,7 @@ void QgsGrass::init( void )
381
381
break ;
382
382
}
383
383
384
- // XXX Need to subclass this and add explantory message above to left side
384
+ // XXX Need to subclass this and add explantory message aboveSencha to left side
385
385
userGisbase = true ;
386
386
// For Mac, GISBASE folder may be inside GRASS bundle. Use Qt file dialog
387
387
// since Mac native dialog doesn't allow user to browse inside bundles.
@@ -412,16 +412,18 @@ void QgsGrass::init( void )
412
412
}
413
413
414
414
QgsDebugMsg ( QString ( " Valid GRASS gisBase is: %1" ).arg ( gisBase ) );
415
+ // GISBASE environment variable must be set because is required by directly called GRASS functions
415
416
putEnv ( " GISBASE" , gisBase );
417
+ mGisbase = gisBase;
416
418
417
419
// Create list of paths to GRASS modules
418
420
// PATH environment variable is not used to search for modules (since 2.12) because it could
419
421
// create a lot of confusion especially if both GRASS 6 and 7 are installed and path to one version
420
422
// $GISBASE/bin somehow gets to PATH and another version plugin is loaded to QGIS, because if a module
421
423
// is missing in one version, it could be found in another $GISBASE/bin and misleadin error could be reported
422
424
mGrassModulesPaths .clear ();
423
- mGrassModulesPaths << gisBase + " /bin" ;
424
- mGrassModulesPaths << gisBase + " /scripts" ;
425
+ mGrassModulesPaths << gisbase () + " /bin" ;
426
+ mGrassModulesPaths << gisbase () + " /scripts" ;
425
427
mGrassModulesPaths << QgsApplication::pkgDataPath () + " /grass/scripts" ;
426
428
427
429
// On windows the GRASS libraries are in
@@ -450,7 +452,7 @@ void QgsGrass::init( void )
450
452
451
453
// TODO: move setting of PYTHONPATH to QProcess where necessary
452
454
// Set PYTHONPATH
453
- QString pythonpath = gisBase + " /etc/python" ;
455
+ QString pythonpath = gisbase () + " /etc/python" ;
454
456
QString pp = getenv ( " PYTHONPATH" );
455
457
pythonpath.append ( pathSeparator () + pp );
456
458
QgsDebugMsg ( QString ( " set PYTHONPATH: %1" ).arg ( pythonpath ) );
@@ -609,6 +611,7 @@ QgsGrass::GERROR QgsGrass::lastError = QgsGrass::OK;
609
611
610
612
QString QgsGrass::error_message;
611
613
614
+ QString QgsGrass::mGisbase ;
612
615
QStringList QgsGrass::mGrassModulesPaths ;
613
616
QString QgsGrass::defaultGisdbase;
614
617
QString QgsGrass::defaultLocation;
@@ -685,8 +688,7 @@ QString QgsGrass::openMapset( const QString& gisdbase,
685
688
QString mapsetPath = gisdbase + " /" + location + " /" + mapset;
686
689
687
690
// Check if the mapset is in use
688
- QString gisBase = getenv ( " GISBASE" );
689
- if ( gisBase.isEmpty () )
691
+ if ( !isValidGrassBaseDir ( gisbase () ) )
690
692
return QObject::tr ( " GISBASE is not set." );
691
693
692
694
QFileInfo fi ( mapsetPath + " /WIND" );
@@ -708,7 +710,7 @@ QString QgsGrass::openMapset( const QString& gisdbase,
708
710
#ifndef Q_OS_WIN
709
711
QFile lockFile ( lock );
710
712
QProcess process;
711
- QString lockProgram ( gisBase + " /etc/lock" );
713
+ QString lockProgram ( gisbase () + " /etc/lock" );
712
714
QStringList lockArguments;
713
715
lockArguments << lock << QString::number ( pid );
714
716
QString lockCommand = lockProgram + " " + lockArguments.join ( " " ); // for debug
@@ -2028,7 +2030,7 @@ QMap<QString, QString> QgsGrass::query( QString gisdbase, QString location, QStr
2028
2030
void QgsGrass::renameObject ( const QgsGrassObject & object, const QString& newName )
2029
2031
{
2030
2032
QgsDebugMsg ( " entered" );
2031
- QString cmd = " g.rename" ;
2033
+ QString cmd = gisbase () + " /bin/ g.rename" ;
2032
2034
QStringList arguments;
2033
2035
2034
2036
arguments << object.elementShort () + " =" + object.name () + " ," + newName;
@@ -2048,7 +2050,7 @@ void QgsGrass::copyObject( const QgsGrassObject & srcObject, const QgsGrassObjec
2048
2050
throw QgsGrass::Exception ( QObject::tr ( " Attempt to copy from different location." ) );
2049
2051
}
2050
2052
2051
- QString cmd = " g.copy" ;
2053
+ QString cmd = gisbase () + " /bin/ g.copy" ;
2052
2054
QStringList arguments;
2053
2055
2054
2056
arguments << srcObject.elementShort () + " =" + srcObject.name () + " @" + srcObject.mapset () + " ," + destObject.name ();
@@ -2074,8 +2076,7 @@ bool QgsGrass::deleteObject( const QgsGrassObject & object )
2074
2076
}
2075
2077
*/
2076
2078
2077
- // path to g.remove should be in PATH (added by QgsGrass::init())
2078
- QString cmd = " g.remove" ;
2079
+ QString cmd = gisbase () + " /bin/g.remove" ;
2079
2080
QStringList arguments;
2080
2081
2081
2082
#if GRASS_VERSION_MAJOR < 7
0 commit comments