Skip to content

Commit a6e14ad

Browse files
author
jef
committed
use cmd.exe on windows for grass
git-svn-id: http://svn.osgeo.org/qgis/trunk@10130 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent def3abc commit a6e14ad

File tree

3 files changed

+20
-47
lines changed

3 files changed

+20
-47
lines changed

src/plugins/grass/qgsgrassmodule.cpp

+17-21
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ QString QgsGrassModule::findExec( QString file )
8787

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

90-
// Search for module
90+
#ifdef WIN32
91+
// On windows try .bat first
9192
for ( QStringList::iterator it = mExecPath.begin();
9293
it != mExecPath.end(); ++it )
9394
{
94-
QString full = *it + "/" + file;
95+
QString full = *it + "/" + file + ".bat";
9596
if ( QFile::exists( full ) )
9697
{
9798
return full;
9899
}
99100
}
100101

101-
// Not found try with .exe
102-
#ifdef WIN32
102+
// .exe next
103103
for ( QStringList::iterator it = mExecPath.begin();
104104
it != mExecPath.end(); ++it )
105105
{
@@ -109,8 +109,21 @@ QString QgsGrassModule::findExec( QString file )
109109
return full;
110110
}
111111
}
112+
113+
// and then try if it's a script (w/o extension)
112114
#endif
113115

116+
// Search for module
117+
for ( QStringList::iterator it = mExecPath.begin();
118+
it != mExecPath.end(); ++it )
119+
{
120+
QString full = *it + "/" + file;
121+
if ( QFile::exists( full ) )
122+
{
123+
return full;
124+
}
125+
}
126+
114127
return QString();
115128
}
116129

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

134-
#if defined(WIN32)
135-
QFileInfo fi( exe );
136-
if ( fi.isExecutable() )
137-
{
138-
arguments.append( exe );
139-
}
140-
else // script
141-
{
142-
QString cmd = getShortPath( QgsApplication::applicationDirPath() ) + "/msys/bin/sh";
143-
arguments.append( cmd );
144-
145-
// Important! Otherwise it does not find DLL even if it is in PATH
146-
arguments.append( "--login" );
147-
arguments.append( exe );
148-
}
149-
#else
150147
arguments.append( exe );
151-
#endif
152148

153149
return arguments;
154150
}

src/plugins/grass/qgsgrassshell.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ QgsGrassShell::QgsGrassShell( QgsGrassTools *tools,
183183
setsid();
184184
seteuid( 0 );
185185

186-
int fd = open(( char* ) slaveName.ascii(), O_RDWR );
186+
int fd = ::open(( char* ) slaveName.ascii(), O_RDWR );
187187
if ( fd < 0 )
188188
{
189189
QMessageBox::warning( 0, "Warning", "Cannot open slave file "

src/plugins/grass/qgsgrasstools.cpp

+2-25
Original file line numberDiff line numberDiff line change
@@ -170,31 +170,8 @@ void QgsGrassTools::runModule( QString name )
170170
#endif
171171

172172
#ifdef WIN32
173-
// Run MSYS if available
174-
// Note: I was not able to run cmd.exe and command.com
175-
// with QProcess
176-
177-
QString msysPath = appDir() + "/msys/bin/rxvt.exe";
178-
QString myArguments = "-backspacekey ^H -sl 2500 -fg white -bg black -sr -fn Courier-16 -tn msys -geometry 80x25 -e /bin/sh --login -i";
179-
QFile file( msysPath );
180-
181-
if ( !file.exists() )
182-
{
183-
QMessageBox::warning( 0, tr( "Warning" ),
184-
tr( "Cannot find MSYS (%1)" ).arg( msysPath ) );
185-
}
186-
else
187-
{
188-
QProcess *proc = new QProcess( this );
189-
//allow msys to exist in a path with spaces
190-
msysPath = "\"" + msysPath + "\"" ;
191-
proc->start( msysPath + " " + myArguments );
192-
proc->waitForStarted();
193-
if ( proc->state() != QProcess::Running )
194-
{
195-
QMessageBox::warning( 0, "Warning",
196-
tr( "Cannot start MSYS (%1)" ).arg( msysPath ) );
197-
}
173+
if( !QProcess::startDetached( getenv("COMSPEC") ) ) {
174+
QMessageBox::warning( 0, "Warning", tr("Cannot start command shell (%1)").arg( getenv("COMSPEC") ) );
198175
}
199176
return;
200177
#else

0 commit comments

Comments
 (0)