Skip to content

Commit 8c8a123

Browse files
committed
[GRASS] fixed crash when GISRC is set but file does not exist or it is corrupted
1 parent e8587c3 commit 8c8a123

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/providers/grass/qgsgrass.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,21 @@ void GRASS_LIB_EXPORT QgsGrass::init( void )
237237
QSettings settings;
238238

239239
// Is it active mode ?
240+
active = false;
240241
if ( getenv( "GISRC" ) )
241242
{
242-
active = true;
243-
// Store default values
244-
defaultGisdbase = G_gisdbase();
245-
defaultLocation = G_location();
246-
defaultMapset = G_mapset();
247-
}
248-
else
249-
{
250-
active = false;
243+
G_TRY
244+
{
245+
// Store default values
246+
defaultGisdbase = G_gisdbase();
247+
defaultLocation = G_location();
248+
defaultMapset = G_mapset();
249+
active = true;
250+
}
251+
G_CATCH( QgsGrass::Exception &e )
252+
{
253+
QgsDebugMsg( QString( "GISRC set but cannot get gisdbase/location/mapset: %1" ).arg( e.what() ) );
254+
}
251255
}
252256

253257
// Don't use GISRC file and read/write GRASS variables (from location G_VAR_GISRC) to memory only.

0 commit comments

Comments
 (0)