Skip to content
Permalink
Browse files
use cmd.exe on windows for grass
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10130 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 8, 2009
1 parent 7434139 commit f0dbe7bb8cbf8af036efd7b8c086fda231eb4ffb
Showing with 20 additions and 47 deletions.
  1. +17 −21 src/plugins/grass/qgsgrassmodule.cpp
  2. +1 −1 src/plugins/grass/qgsgrassshell.cpp
  3. +2 −25 src/plugins/grass/qgsgrasstools.cpp
@@ -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 )
{
@@ -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();
}

@@ -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;
}
@@ -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 "
@@ -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

0 comments on commit f0dbe7b

Please sign in to comment.