Skip to content

Commit

Permalink
store GISBASE only if defined by user
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@4856 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Feb 15, 2006
1 parent d7148fb commit c100cc5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -63,7 +63,6 @@ void QgsGrass::init( void )
// Set program name
G_set_program_name ("QGIS");


// Require GISBASE to be set. This should point to the location of
// the GRASS installation. The GRASS libraries use it to know
// where to look for things.
Expand All @@ -86,6 +85,9 @@ void QgsGrass::init( void )
}

if ( !isValidGrassBaseDir(gisBase) ) {
// Erase gisbase from settings because it does not exists
settings.writeEntry("/GRASS/gisbase", "");

#ifdef WIN32
// Use the applicationDirPath()/grass
gisBase = QCoreApplication::applicationDirPath() + "/grass";
Expand All @@ -103,21 +105,29 @@ void QgsGrass::init( void )
#endif
}

bool userGisbase = false;
while ( !isValidGrassBaseDir(gisBase) ) {
// Keep asking user for GISBASE until we get a valid one
//QMessageBox::warning( 0, "Warning", "QGIS can't find your GRASS installation,\nGRASS data "
// "cannot be used.\nPlease select your GISBASE.\nGISBASE is full path to the\n"
// "directory where GRASS is installed." );
// XXX Need to subclass this and add explantory message above to left side
userGisbase = true;
gisBase = QFileDialog::getExistingDirectory(
0, "Choose GISBASE ...", gisBase);
if (gisBase == QString::null)
{
// User pressed cancel. No GRASS for you!
return;
userGisbase = false;
break;
}
}

if ( userGisbase )
{
settings.writeEntry("/GRASS/gisbase", gisBase);
}

#ifdef QGISDEBUG
qDebug( "%s:%d Valid GRASS gisBase is: %s", __FILE__, __LINE__, (const char*)gisBase );
#endif
Expand All @@ -126,7 +136,6 @@ void QgsGrass::init( void )
char *gisBaseEnvChar = new char[gisBaseEnv.length()+1];
strcpy ( gisBaseEnvChar, const_cast<char *>(gisBaseEnv.ascii()) );
putenv( gisBaseEnvChar );
settings.writeEntry("/GRASS/gisbase", gisBase);

// Add path to GRASS modules
#ifdef WIN32
Expand Down

0 comments on commit c100cc5

Please sign in to comment.