Skip to content

Commit c4d8e5a

Browse files
committedDec 11, 2012
More info if GRASS modules fails. G__getenv to see if it moves forward on Windows.
1 parent d5bc39c commit c4d8e5a

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed
 

‎src/plugins/grass/qgsgrassmodule.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,13 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
338338

339339
QProcess process( this );
340340

341+
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
341342
if ( mDirect )
342343
{
343344
// Set path to GRASS gis fake library
344-
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
345345

346346
QgsGrassModule::setDirectLibraryPath( environment );
347-
environment.insert( "QGIS_PREFIX", QgsApplication::prefixPath() );
347+
environment.insert( "QGIS_PREFIX_PATH", QgsApplication::prefixPath() );
348348
// Window to avoid crash in G__gisinit
349349
environment.insert( "GRASS_REGION", "west:0;south:0;east:1;north:1;cols:1;rows:1;proj:0;zone:0" );
350350
process.setProcessEnvironment( environment );
@@ -361,8 +361,11 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
361361
|| ( process.exitCode() != 0 && process.exitCode() != 255 &&
362362
( !cmd.endsWith( ".py" ) || process.exitCode() != 1 ) ) )
363363
{
364+
QString pathVariable = QgsGrassModule::libraryPathVariable();
364365
QgsDebugMsg( "process.exitCode() = " + QString::number( process.exitCode() ) );
365366
QString msg = tr( "Cannot start module %1" ).arg( mXName )
367+
+ "<br>" + pathVariable + "=" + environment.value( pathVariable )
368+
+ "<br>QGIS_PREFIX_PATH=" + environment.value( "QGIS_PREFIX_PATH" )
366369
+ tr( "<br>command: %1 %2<br>%3<br>%4" )
367370
.arg( cmd ).arg( arguments.join( " " ) )
368371
.arg( process.readAllStandardOutput().constData() )
@@ -1996,18 +1999,26 @@ QDomNode QgsGrassModule::nodeByKey( QDomElement elem, QString key )
19961999
return QDomNode();
19972000
}
19982001

2002+
QString QgsGrassModule::libraryPathVariable()
2003+
{
2004+
#ifdef Q_OS_WIN
2005+
return "PATH";
2006+
#elif defined(Q_OS_MAC)
2007+
return "DYLD_LIBRARY_PATH";
2008+
#else
2009+
return "LD_LIBRARY_PATH";
2010+
#endif
2011+
}
2012+
19992013
void QgsGrassModule::setDirectLibraryPath( QProcessEnvironment & environment )
20002014
{
2001-
QString pathVariable;
2015+
QString pathVariable = libraryPathVariable();
20022016
QString separator;
20032017
#ifdef Q_OS_WIN
2004-
pathVariable = "PATH";
20052018
separator = ";";
20062019
#elif defined(Q_OS_MAC)
2007-
pathVariable = "DYLD_LIBRARY_PATH";
20082020
separator = ":";
20092021
#else
2010-
pathVariable = "LD_LIBRARY_PATH";
20112022
separator = ":";
20122023
#endif
20132024
QString lp = environment.value( pathVariable );

‎src/plugins/grass/qgsgrassmodule.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class QgsGrassModule: public QDialog, private Ui::QgsGrassModuleBase
111111
//! Returns true if module is direct
112112
bool isDirect() { return mDirect; }
113113

114+
//! Get name of library path environment variable
115+
static QString libraryPathVariable();
116+
114117
//! Set LD_LIBRARY_PATH or equivalent to GRASS Direct library
115118
static void setDirectLibraryPath( QProcessEnvironment & environment );
116119

‎src/providers/grass/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ SET ( FUNCTIONS
7171
"G_define_standard_option"
7272
"G_free"
7373
"G_free_raster_cats"
74+
"G__getenv"
7475
"G_get_fp_range_min_max"
7576
"G_get_range_min_max"
7677
"G_get_window"

0 commit comments

Comments
 (0)
Please sign in to comment.