Skip to content

Commit

Permalink
grass provider: catch unavailable mapserver (fixes #11025)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Aug 30, 2014
1 parent 00ca017 commit a351385
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -364,22 +364,7 @@ QString QgsGrass::getDefaultMapset( void )
void QgsGrass::setLocation( QString gisdbase, QString location )
{
QgsDebugMsg( QString( "gisdbase = %1 location = %2" ).arg( gisdbase ).arg( location ) );
init();

// Set principal GRASS variables (in memory)
#ifdef Q_OS_WIN
G__setenv( "GISDBASE", shortPath( gisdbase ).toLocal8Bit().data() );
#else
// This does not work for GISBASE with non ascii chars on Windows XP,
// gives error 'LOCATION ... not available':
G__setenv( "GISDBASE", gisdbase.toUtf8().constData() );
#endif
G__setenv( "LOCATION_NAME", location.toUtf8().constData() );
G__setenv( "MAPSET", "PERMANENT" ); // PERMANENT must always exist

// Add all available mapsets to search path
char **ms = G_available_mapsets();
for ( int i = 0; ms[i]; i++ ) G_add_mapset_to_search_path( ms[i] );
setMapset( gisdbase, location, "PERMANENT" );
}

void QgsGrass::setMapset( QString gisdbase, QString location, QString mapset )
Expand All @@ -397,8 +382,20 @@ void QgsGrass::setMapset( QString gisdbase, QString location, QString mapset )
G__setenv( "MAPSET", mapset.toUtf8().data() );

// Add all available mapsets to search path
char **ms = G_available_mapsets();
for ( int i = 0; ms[i]; i++ ) G_add_mapset_to_search_path( ms[i] );
char **ms = 0;
G_TRY
{
ms = G_available_mapsets();
}
G_CATCH( QgsGrass::Exception &e )
{
Q_UNUSED( e );
QgsDebugMsg( QString( "No available mapsets found: %1" ).arg( e.what() ) );
return;
}

for ( int i = 0; ms[i]; i++ )
G_add_mapset_to_search_path( ms[i] );
}

jmp_buf QgsGrass::jumper;
Expand Down

0 comments on commit a351385

Please sign in to comment.