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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Mar 3 14:17:31 EST 2010


Author: rblazek
Date: 2010-03-03 14:17:30 -0500 (Wed, 03 Mar 2010)
New Revision: 12995

Modified:
   trunk/qgis/src/plugins/grass/qgsgrassshell.cpp
Log:
do not run Init.sh in terminal, GRASS is already started if QGIS is run from GRASS shell or everything is set by QgsGrass::openMapset

Modified: trunk/qgis/src/plugins/grass/qgsgrassshell.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassshell.cpp	2010-03-03 15:12:30 UTC (rev 12994)
+++ trunk/qgis/src/plugins/grass/qgsgrassshell.cpp	2010-03-03 19:17:30 UTC (rev 12995)
@@ -46,38 +46,18 @@
   connect( copyShortcut, SIGNAL( activated() ), mTerminal, SLOT( copyClipboard() ) );
 
   // TODO: find a better way to manage the lockfile.
+  // Locking should not be done here, a mapset is either locked by GRASS if QGIS is started from GRASS or it is created by QgsGrass::openMapset
+  /*
   mLockFilename = QgsGrass::lockFilePath();
   QFile::remove( mLockFilename + ".qgis" );
   if ( !QFile::rename( mLockFilename, mLockFilename + ".qgis" ) )
   {
     QMessageBox::warning( this, tr( "Warning" ), tr( "Cannot rename the lock file %1" ).arg( mLockFilename ) );
   }
+  */
 
   mTerminal->setSize( 80, 25 );
   mTerminal->startShellProgram();
-  // using -text option GRASS_GUI is owerridden so we have to reset it 
-  QgsDebugMsg ( "gisrc = " + QgsGrass::gisrcFilePath() );
-  QFile in( QgsGrass::gisrcFilePath() );
-  if ( in.open( QIODevice::ReadOnly ) ) 
-  {
-    char buf[1000];
-    QString oldGui;
-    while ( in.readLine( buf, 1000 ) != -1 )
-    {
-      QString line = buf;
-      QStringList kv = line.split ( ':' );
-      if ( kv.length() == 2 &&  kv.at(0) == "GRASS_GUI" ) 
-      {
-        oldGui = kv.at(1).trimmed ();
-        break;
-      }
-    }
-    if ( ! oldGui.isEmpty() ) 
-    {
-      QString cmd = QString("g.gisenv set=GRASS_GUI=") + oldGui + "\n";
-      mTerminal->sendText( cmd );
-    }
-  }
   mTerminal->setFocus( Qt::MouseFocusReason );
 }
 
@@ -91,11 +71,13 @@
   mTabWidget->removeTab( index );
 
   // TODO: find a better way to manage the lockfile.
+  // No locking should be done here, see above
+  /*
   if ( !QFile::rename( mLockFilename + ".qgis", mLockFilename ) )
   {
     QMessageBox::warning( this, tr( "Warning" ), tr( "Cannot rename the lock file %1" ).arg( mLockFilename ) );
   }
-
+  */
   this->deleteLater();
 }
 
@@ -104,18 +86,22 @@
   QStringList env( "" );
   QStringList args( "" );
 
-  QString shellProgram = QString( "%1/etc/Init.sh" ).arg( ::getenv( "GISBASE" ) );
+  // GRASS Init.sh should not be started here, it is either run when GRASS is started if QGIS is run from GRASS shell or everything (set environment variables and lock mapset) is done in QgsGrass::openMapset
+  //QString shellProgram = QString( "%1/etc/Init.sh" ).arg( ::getenv( "GISBASE" ) );
 
-  terminal->setShellProgram( shellProgram );
+  //terminal->setShellProgram( shellProgram );
   env << "TERM=vt100";
   env << "GISRC_MODE_MEMORY";
-  // This is also overriden by Init.sh, it should not be run at all, either QGIS is started from shell or a mapset is open from QGIS, Init.sh opens the session second time
+  // TODO: we should check if these environment variable were set by user before QGIS was started
   env << "GRASS_HTML_BROWSER=" + QgsApplication::pkgDataPath() + "/grass/bin/qgis.g.browser";
+  env << "GRASS_WISH=wish";
+  env << "GRASS_TCLSH=tclsh";
+  env << "GRASS_PYTHON=python";
 
-  args << "-text";
-  args << QString( "%1/%2/%3" ).arg( QgsGrass::getDefaultGisdbase() ).arg( QgsGrass::getDefaultLocation() ).arg( QgsGrass::getDefaultMapset() );
+  //args << "-text";
+  //args << QString( "%1/%2/%3" ).arg( QgsGrass::getDefaultGisdbase() ).arg( QgsGrass::getDefaultLocation() ).arg( QgsGrass::getDefaultMapset() );
 
-  terminal->setArgs( args );
+  //terminal->setArgs( args );
   terminal->setEnvironment( env );
 
   // Look & Feel



More information about the QGIS-commit mailing list