Skip to content
Permalink
Browse files
GRASS Direct: Mac DYLD_LIBRARY_PATH fix
  • Loading branch information
blazek committed Dec 10, 2012
1 parent 452f8da commit df2c1c5a8d0db10d5c007aa33fcb8457a4529f53
Showing with 30 additions and 19 deletions.
  1. +25 −19 src/plugins/grass/qgsgrassmodule.cpp
  2. +3 −0 src/plugins/grass/qgsgrassmodule.h
  3. +2 −0 src/providers/grass/qgsgrassgislib.cpp
@@ -342,17 +342,8 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
{
// Set path to GRASS gis fake library
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
#ifdef Q_OS_WIN
QString lp = environment.value( "PATH" );
lp = QgsApplication::pluginPath() + ";" + lp;
environment.insert( "PATH", lp );
QgsDebugMsg( "PATH=" + lp );
#else
QString lp = environment.value( "LD_LIBRARY_PATH" );
lp = QgsApplication::pluginPath() + ":" + lp;
environment.insert( "LD_LIBRARY_PATH", lp );
QgsDebugMsg( "LD_LIBRARY_PATH=" + lp );
#endif

QgsGrassModule::setDirectLibraryPath( environment );
environment.insert( "QGIS_PREFIX", 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" );
@@ -1644,17 +1635,12 @@ void QgsGrassModule::run()
if ( mDirect )
{
QStringList variables;
setDirectLibraryPath( environment );
#ifdef Q_OS_WIN
QString lp = environment.value( "PATH" );
lp = QgsApplication::pluginPath() + ";" + lp;
environment.insert( "PATH", lp );
QgsDebugMsg( "PATH=" + lp );
variables << "PATH";
#elif Q_OS_MAC
variables << "DYLD_LIBRARY_PATH";
#else
QString lp = environment.value( "LD_LIBRARY_PATH" );
lp = QgsApplication::pluginPath() + ":" + lp;
environment.insert( "LD_LIBRARY_PATH", lp );
QgsDebugMsg( "LD_LIBRARY_PATH=" + lp );
variables << "LD_LIBRARY_PATH";
#endif
environment.insert( "QGIS_PREFIX_PATH", QgsApplication::prefixPath() );
@@ -2010,6 +1996,26 @@ QDomNode QgsGrassModule::nodeByKey( QDomElement elem, QString key )
return QDomNode();
}

void QgsGrassModule::setDirectLibraryPath( QProcessEnvironment & environment )
{
QString pathVariable;
QString separator;
#ifdef Q_OS_WIN
pathVariable = "PATH";
separator = ";";
#elif Q_OS_MAC
pathVariable = "DYLD_LIBRARY_PATH";
separator = ":";
#else
pathVariable = "LD_LIBRARY_PATH";
separator = ":";
#endif
QString lp = environment.value( pathVariable );
lp = QgsApplication::pluginPath() + separator + lp;
environment.insert( pathVariable, lp );
QgsDebugMsg( pathVariable + "=" + lp );
}

/******************* QgsGrassModuleOption ****************************/

QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key,
@@ -111,6 +111,9 @@ class QgsGrassModule: public QDialog, private Ui::QgsGrassModuleBase
//! Returns true if module is direct
bool isDirect() { return mDirect; }

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

signals:
// ! emitted when the module started
void moduleStarted();
@@ -17,7 +17,9 @@
#include <stdio.h>
#include <stdarg.h>

#ifdef Q_OS_WIN
#include "qgsgrassgislibfunctions.h"
#endif
#include "qgsgrassgislib.h"

#include "qgslogger.h"

0 comments on commit df2c1c5

Please sign in to comment.