[QGIS Commit] r10130 - trunk/qgis/src/plugins/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Feb 8 13:14:04 EST 2009


Author: jef
Date: 2009-02-08 13:14:04 -0500 (Sun, 08 Feb 2009)
New Revision: 10130

Modified:
   trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
   trunk/qgis/src/plugins/grass/qgsgrassshell.cpp
   trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
Log:
use cmd.exe on windows for grass

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2009-02-08 18:12:07 UTC (rev 10129)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2009-02-08 18:14:04 UTC (rev 10130)
@@ -87,19 +87,19 @@
 
   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 @@
       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 @@
     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;
 }

Modified: trunk/qgis/src/plugins/grass/qgsgrassshell.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassshell.cpp	2009-02-08 18:12:07 UTC (rev 10129)
+++ trunk/qgis/src/plugins/grass/qgsgrassshell.cpp	2009-02-08 18:14:04 UTC (rev 10130)
@@ -183,7 +183,7 @@
     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 "

Modified: trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrasstools.cpp	2009-02-08 18:12:07 UTC (rev 10129)
+++ trunk/qgis/src/plugins/grass/qgsgrasstools.cpp	2009-02-08 18:14:04 UTC (rev 10130)
@@ -170,32 +170,9 @@
 #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 ) );
+    if( !QProcess::startDetached( getenv("COMSPEC") ) ) {
+      QMessageBox::warning( 0, "Warning", tr("Cannot start command shell (%1)").arg( getenv("COMSPEC") ) );
     }
-    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 ) );
-      }
-    }
     return;
 #else
 



More information about the QGIS-commit mailing list