Skip to content
Permalink
Browse files
More info if GRASS modules fails. G__getenv to see if it moves forwar…
…d on Windows.
  • Loading branch information
blazek committed Dec 11, 2012
1 parent d5bc39c commit c4d8e5ac12486a66a63938c75a297daee90a23b8
Showing with 21 additions and 6 deletions.
  1. +17 −6 src/plugins/grass/qgsgrassmodule.cpp
  2. +3 −0 src/plugins/grass/qgsgrassmodule.h
  3. +1 −0 src/providers/grass/CMakeLists.txt
@@ -338,13 +338,13 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(

QProcess process( this );

QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
if ( mDirect )
{
// Set path to GRASS gis fake library
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();

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

QString QgsGrassModule::libraryPathVariable()
{
#ifdef Q_OS_WIN
return "PATH";
#elif defined(Q_OS_MAC)
return "DYLD_LIBRARY_PATH";
#else
return "LD_LIBRARY_PATH";
#endif
}

void QgsGrassModule::setDirectLibraryPath( QProcessEnvironment & environment )
{
QString pathVariable;
QString pathVariable = libraryPathVariable();
QString separator;
#ifdef Q_OS_WIN
pathVariable = "PATH";
separator = ";";
#elif defined(Q_OS_MAC)
pathVariable = "DYLD_LIBRARY_PATH";
separator = ":";
#else
pathVariable = "LD_LIBRARY_PATH";
separator = ":";
#endif
QString lp = environment.value( pathVariable );
@@ -111,6 +111,9 @@ class QgsGrassModule: public QDialog, private Ui::QgsGrassModuleBase
//! Returns true if module is direct
bool isDirect() { return mDirect; }

//! Get name of library path environment variable
static QString libraryPathVariable();

//! Set LD_LIBRARY_PATH or equivalent to GRASS Direct library
static void setDirectLibraryPath( QProcessEnvironment & environment );

@@ -71,6 +71,7 @@ SET ( FUNCTIONS
"G_define_standard_option"
"G_free"
"G_free_raster_cats"
"G__getenv"
"G_get_fp_range_min_max"
"G_get_range_min_max"
"G_get_window"

0 comments on commit c4d8e5a

Please sign in to comment.