Skip to content

Commit c100cc5

Browse files
author
rblazek
committedFeb 15, 2006
store GISBASE only if defined by user
git-svn-id: http://svn.osgeo.org/qgis/trunk@4856 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent d7148fb commit c100cc5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎src/providers/grass/qgsgrass.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ void QgsGrass::init( void )
6363
// Set program name
6464
G_set_program_name ("QGIS");
6565

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

8887
if ( !isValidGrassBaseDir(gisBase) ) {
88+
// Erase gisbase from settings because it does not exists
89+
settings.writeEntry("/GRASS/gisbase", "");
90+
8991
#ifdef WIN32
9092
// Use the applicationDirPath()/grass
9193
gisBase = QCoreApplication::applicationDirPath() + "/grass";
@@ -103,21 +105,29 @@ void QgsGrass::init( void )
103105
#endif
104106
}
105107

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

126+
if ( userGisbase )
127+
{
128+
settings.writeEntry("/GRASS/gisbase", gisBase);
129+
}
130+
121131
#ifdef QGISDEBUG
122132
qDebug( "%s:%d Valid GRASS gisBase is: %s", __FILE__, __LINE__, (const char*)gisBase );
123133
#endif
@@ -126,7 +136,6 @@ void QgsGrass::init( void )
126136
char *gisBaseEnvChar = new char[gisBaseEnv.length()+1];
127137
strcpy ( gisBaseEnvChar, const_cast<char *>(gisBaseEnv.ascii()) );
128138
putenv( gisBaseEnvChar );
129-
settings.writeEntry("/GRASS/gisbase", gisBase);
130139

131140
// Add path to GRASS modules
132141
#ifdef WIN32

0 commit comments

Comments
 (0)
Please sign in to comment.