[QGIS Commit] r11570 - trunk/qgis/src/providers/grass
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Sep 5 15:45:33 EDT 2009
Author: jef
Date: 2009-09-05 15:45:32 -0400 (Sat, 05 Sep 2009)
New Revision: 11570
Modified:
trunk/qgis/src/providers/grass/qgsgrass.cpp
Log:
fix path corruption in GRASS on windows
Modified: trunk/qgis/src/providers/grass/qgsgrass.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrass.cpp 2009-09-05 18:21:00 UTC (rev 11569)
+++ trunk/qgis/src/providers/grass/qgsgrass.cpp 2009-09-05 19:45:32 UTC (rev 11570)
@@ -42,7 +42,15 @@
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;
}
@@ -173,7 +181,7 @@
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 );
@@ -198,14 +206,15 @@
// 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 );
@@ -214,7 +223,7 @@
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 );
More information about the QGIS-commit
mailing list