Skip to content

Commit bcf10f9

Browse files
committed
[GRASS] fixed shell on windows
1 parent 1582f6a commit bcf10f9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/plugins/grass/qgsgrasstools.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,22 @@ void QgsGrassTools::runModule( QString name, bool direct )
273273
{
274274
#ifdef Q_OS_WIN
275275
QgsGrass::putEnv( "GRASS_HTML_BROWSER", QgsGrassUtils::htmlBrowserPath() );
276+
QStringList env;
277+
QByteArray origPath = qgetenv( "PATH" );
278+
QByteArray origPythonPath = qgetenv( "PYTHONPATH" );
279+
QString path = QString( origPath ) + QgsGrass::pathSeparator() + QgsGrass::grassModulesPaths().join( QgsGrass::pathSeparator() );
280+
QString pythonPath = QString( origPythonPath ) + QgsGrass::pathSeparator() + QgsGrass::getPythonPath();
281+
QgsDebugMsg( "path = " + path );
282+
QgsDebugMsg( "pythonPath = " + pythonPath );
283+
qputenv( "PATH", path.toLocal8Bit() );
284+
qputenv( "PYTHONPATH", pythonPath.toLocal8Bit() );
285+
// QProcess does not support environment for startDetached() -> set/reset to orig
276286
if ( !QProcess::startDetached( getenv( "COMSPEC" ) ) )
277287
{
278288
QMessageBox::warning( 0, "Warning", tr( "Cannot start command shell (%1)" ).arg( getenv( "COMSPEC" ) ) );
279289
}
290+
qputenv( "PATH", origPath );
291+
qputenv( "PYTHONPATH", origPythonPath );
280292
return;
281293
#else
282294

0 commit comments

Comments
 (0)