Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added libraryPath() and libexecPath() to QgsApplication
  • Loading branch information
wonder-sk committed Jul 25, 2011
1 parent c42f1ea commit 257ae38
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 9 deletions.
8 changes: 8 additions & 0 deletions python/core/qgsapplication.sip
Expand Up @@ -185,6 +185,14 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
//! Returns the path to default style (works as a starting point). Added in QGIS 1.4
static const QString defaultStyleV2Path();

//! Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries
//! @note Added in 2.0
static const QString libraryPath();

//! Returns the path with utility executables (help viewer, crssync, ...)
//! @note Added in 2.0
static const QString libexecPath();

//! Alters prefix path - used by 3rd party apps
static void setPrefixPath(const QString thePrefixPath, bool useDefaultPaths = FALSE);

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -4616,7 +4616,7 @@ void QgisApp::loadPythonSupport()
{
QString pythonlibName( "qgispython" );
#if defined(Q_WS_MAC) || defined(Q_OS_LINUX)
pythonlibName.prepend( QgsApplication::prefixPath() + "/" + QGIS_LIB_SUBDIR + "/" );
pythonlibName.prepend( QgsApplication::libraryPath() );
#endif
#ifdef __MINGW32__
pythonlibName.prepend( "lib" );
Expand Down
10 changes: 10 additions & 0 deletions src/core/qgsapplication.cpp
Expand Up @@ -399,6 +399,16 @@ const QString QgsApplication::defaultStyleV2Path()
return mPkgDataPath + QString( "/resources/symbology-ng-style.xml" );
}

const QString QgsApplication::libraryPath()
{
return QgsApplication::prefixPath() + "/" + QGIS_LIB_SUBDIR + "/";
}

const QString QgsApplication::libexecPath()
{
return QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR + "/";
}

QgsApplication::endian_t QgsApplication::endian()
{
return ( htonl( 1 ) == 1 ) ? XDR : NDR ;
Expand Down
8 changes: 8 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -144,6 +144,14 @@ class CORE_EXPORT QgsApplication: public QApplication
//! Returns the path to default style (works as a starting point). Added in QGIS 1.4
static const QString defaultStyleV2Path();

//! Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries
//! @note Added in 2.0
static const QString libraryPath();

//! Returns the path with utility executables (help viewer, crssync, ...)
//! @note Added in 2.0
static const QString libexecPath();

//! Alters prefix path - used by 3rd party apps
static void setPrefixPath( const QString thePrefixPath, bool useDefaultPaths = false );

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -1395,7 +1395,7 @@ void QgsGrassModule::run()
mOutputTextBrowser->append( "<B>" + commandHtml + "</B>" );

QStringList environment = QProcess::systemEnvironment();
environment.append( "GRASS_HTML_BROWSER=" + QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/bin/qgis.g.browser" );
environment.append( "GRASS_HTML_BROWSER=" + QgsApplication::libexecPath() + "grass/bin/qgis.g.browser" );

// Warning: it is not useful to write requested region to WIND file and
// reset then to original beacuse it is reset before
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrassshell.cpp
Expand Up @@ -96,7 +96,7 @@ void QgsGrassShell::initTerminal( QTermWidget *terminal )
env << "TERM=vt100";
env << "GISRC_MODE_MEMORY";
// TODO: we should check if these environment variable were set by user before QGIS was started
env << "GRASS_HTML_BROWSER=" + QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/bin/qgis.g.browser";
env << "GRASS_HTML_BROWSER=" + QgsApplication::libexecPath() + "grass/bin/qgis.g.browser";
env << "GRASS_WISH=wish";
env << "GRASS_TCLSH=tclsh";
env << "GRASS_PYTHON=python";
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrasstools.cpp
Expand Up @@ -144,7 +144,7 @@ void QgsGrassTools::runModule( QString name )
if ( name == "shell" )
{
#ifdef WIN32
QgsGrass::putEnv( "GRASS_HTML_BROWSER", QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/bin/qgis.g.browser" );
QgsGrass::putEnv( "GRASS_HTML_BROWSER", QgsApplication::libexecPath() + "grass/bin/qgis.g.browser" );
if ( !QProcess::startDetached( getenv( "COMSPEC" ) ) )
{
QMessageBox::warning( 0, "Warning", tr( "Cannot start command shell (%1)" ).arg( getenv( "COMSPEC" ) ) );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrass.cpp
Expand Up @@ -1213,7 +1213,7 @@ QString GRASS_LIB_EXPORT QgsGrass::getInfo( QString info, QString gisdbase, QStr

QStringList arguments;

QString cmd = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.g.info";
QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.g.info";

arguments.append( "info=" + info );
if ( !map.isEmpty() )
Expand Down
8 changes: 4 additions & 4 deletions src/providers/grass/qgsgrassrasterprovider.cpp
Expand Up @@ -125,7 +125,7 @@ QImage* QgsGrassRasterProvider::draw( QgsRectangle const & viewExtent, int pixe
.arg( viewExtent.xMaximum() ).arg( viewExtent.yMaximum() )
.arg( pixelWidth ).arg( pixelHeight ) ) );
QProcess process( this );
QString cmd = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.d.rast";
QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.d.rast";
QByteArray data;
try
{
Expand Down Expand Up @@ -177,7 +177,7 @@ void QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void

arguments.append( "format=value" );
QProcess process( this );
QString cmd = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.d.rast";
QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.d.rast";
QByteArray data;
try
{
Expand Down Expand Up @@ -223,7 +223,7 @@ void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const & viewEx
.arg( pixelWidth ).arg( pixelHeight ) ) );
arguments.append( "format=value" );
QProcess process( this );
QString cmd = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.d.rast";
QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.d.rast";
QByteArray data;
try
{
Expand Down Expand Up @@ -558,7 +558,7 @@ void QgsGrassRasterValue::start( QString gisdbase, QString location,
mMapset = mapset;
mMapName = map;
// TODO: catch exceptions
QString module = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.g.info";
QString module = QgsApplication::libexecPath() + "grass/modules/qgis.g.info";
QStringList arguments;

arguments.append( "info=query" );
Expand Down

0 comments on commit 257ae38

Please sign in to comment.