Skip to content

Commit

Permalink
GRASS Direct: Mac DYLD_LIBRARY_PATH fix
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Dec 10, 2012
1 parent 452f8da commit df2c1c5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -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" );
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/grass/qgsgrassmodule.h
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/providers/grass/qgsgrassgislib.cpp
Expand Up @@ -17,7 +17,9 @@
#include <stdio.h>
#include <stdarg.h>

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

#include "qgslogger.h"
Expand Down

0 comments on commit df2c1c5

Please sign in to comment.