Navigation Menu

Skip to content

Commit

Permalink
use cmd.exe on windows for grass
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@10130 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 8, 2009
1 parent def3abc commit a6e14ad
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 47 deletions.
38 changes: 17 additions & 21 deletions src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -87,19 +87,19 @@ QString QgsGrassModule::findExec( QString file )

if ( QFile::exists( file ) ) return file; // full path

// Search for module
#ifdef WIN32
// On windows try .bat first
for ( QStringList::iterator it = mExecPath.begin();
it != mExecPath.end(); ++it )
{
QString full = *it + "/" + file;
QString full = *it + "/" + file + ".bat";
if ( QFile::exists( full ) )
{
return full;
}
}

// Not found try with .exe
#ifdef WIN32
// .exe next
for ( QStringList::iterator it = mExecPath.begin();
it != mExecPath.end(); ++it )
{
Expand All @@ -109,8 +109,21 @@ QString QgsGrassModule::findExec( QString file )
return full;
}
}

// and then try if it's a script (w/o extension)
#endif

// Search for module
for ( QStringList::iterator it = mExecPath.begin();
it != mExecPath.end(); ++it )
{
QString full = *it + "/" + file;
if ( QFile::exists( full ) )
{
return full;
}
}

return QString();
}

Expand All @@ -131,24 +144,7 @@ QStringList QgsGrassModule::execArguments( QString module )
return arguments;
}

#if defined(WIN32)
QFileInfo fi( exe );
if ( fi.isExecutable() )
{
arguments.append( exe );
}
else // script
{
QString cmd = getShortPath( QgsApplication::applicationDirPath() ) + "/msys/bin/sh";
arguments.append( cmd );

// Important! Otherwise it does not find DLL even if it is in PATH
arguments.append( "--login" );
arguments.append( exe );
}
#else
arguments.append( exe );
#endif

return arguments;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrassshell.cpp
Expand Up @@ -183,7 +183,7 @@ QgsGrassShell::QgsGrassShell( QgsGrassTools *tools,
setsid();
seteuid( 0 );

int fd = open(( char* ) slaveName.ascii(), O_RDWR );
int fd = ::open(( char* ) slaveName.ascii(), O_RDWR );
if ( fd < 0 )
{
QMessageBox::warning( 0, "Warning", "Cannot open slave file "
Expand Down
27 changes: 2 additions & 25 deletions src/plugins/grass/qgsgrasstools.cpp
Expand Up @@ -170,31 +170,8 @@ void QgsGrassTools::runModule( QString name )
#endif

#ifdef WIN32
// Run MSYS if available
// Note: I was not able to run cmd.exe and command.com
// with QProcess

QString msysPath = appDir() + "/msys/bin/rxvt.exe";
QString myArguments = "-backspacekey ^H -sl 2500 -fg white -bg black -sr -fn Courier-16 -tn msys -geometry 80x25 -e /bin/sh --login -i";
QFile file( msysPath );

if ( !file.exists() )
{
QMessageBox::warning( 0, tr( "Warning" ),
tr( "Cannot find MSYS (%1)" ).arg( msysPath ) );
}
else
{
QProcess *proc = new QProcess( this );
//allow msys to exist in a path with spaces
msysPath = "\"" + msysPath + "\"" ;
proc->start( msysPath + " " + myArguments );
proc->waitForStarted();
if ( proc->state() != QProcess::Running )
{
QMessageBox::warning( 0, "Warning",
tr( "Cannot start MSYS (%1)" ).arg( msysPath ) );
}
if( !QProcess::startDetached( getenv("COMSPEC") ) ) {
QMessageBox::warning( 0, "Warning", tr("Cannot start command shell (%1)").arg( getenv("COMSPEC") ) );
}
return;
#else
Expand Down

0 comments on commit a6e14ad

Please sign in to comment.