Skip to content

Commit

Permalink
fix path corruption in GRASS on windows
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11570 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Sep 5, 2009
1 parent b383c7f commit a7f4136
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/providers/grass/qgsgrass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ extern "C"
QString GRASS_EXPORT QgsGrass::shortPath( const QString &path )
{
TCHAR buf[MAX_PATH];
GetShortPathName( path.toUtf8().constData(), buf, MAX_PATH );
int len = GetShortPathName( path.toUtf8().constData(), buf, MAX_PATH );

if ( len == 0 || len > MAX_PATH )
{
QgsDebugMsg( QString( "GetShortPathName('%1') failed with %2: %3" )
.arg( path ).arg( len ).arg( GetLastError() ) );
return path;
}

QString res = QString::fromUtf8( buf );
return res;
}
Expand Down Expand Up @@ -173,7 +181,7 @@ void GRASS_EXPORT QgsGrass::init( void )
QgsDebugMsg( QString( "Valid GRASS gisBase is: %1" ).arg( gisBase ) );
QString gisBaseEnv = "GISBASE=" + gisBase;
/* _Correct_ putenv() implementation is not making copy! */
char *gisBaseEnvChar = new char[gisBaseEnv.length()+1];
char *gisBaseEnvChar = new char[gisBaseEnv.toUtf8().length()+1];
strcpy( gisBaseEnvChar, gisBaseEnv.toUtf8().constData() );
putenv( gisBaseEnvChar );

Expand All @@ -198,14 +206,15 @@ void GRASS_EXPORT QgsGrass::init( void )

// Add path to MSYS bin
// Warning: MSYS sh.exe will translate this path to '/bin'
path.append( sep + shortPath( QCoreApplication::applicationDirPath() + "/msys/bin/" ) );
if ( QFileInfo( QCoreApplication::applicationDirPath() + "/msys/bin/" ).isDir() )
path.append( sep + shortPath( QCoreApplication::applicationDirPath() + "/msys/bin/" ) );
#endif

QString p = getenv( "PATH" );
path.append( sep + p );

QgsDebugMsg( QString( "set PATH: %1" ).arg( path ) );
char *pathEnvChar = new char[path.length()+1];
char *pathEnvChar = new char[path.toUtf8().length()+1];
strcpy( pathEnvChar, path.toUtf8().constData() );
putenv( pathEnvChar );

Expand All @@ -214,7 +223,7 @@ void GRASS_EXPORT QgsGrass::init( void )
QString pp = getenv( "PATH" );
pythonpath.append( sep + pp );
QgsDebugMsg( QString( "set PYTHONPATH: %1" ).arg( pythonpath ) );
char *pythonpathEnvChar = new char[pythonpath.length()+1];
char *pythonpathEnvChar = new char[pythonpath.toUtf8().length()+1];
strcpy( pythonpathEnvChar, pythonpath.toUtf8().constData() );
putenv( pythonpathEnvChar );

Expand Down

0 comments on commit a7f4136

Please sign in to comment.