[QGIS Commit] r12919 - in trunk/qgis/src: plugins/grass providers/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Feb 10 10:35:46 EST 2010


Author: rblazek
Date: 2010-02-10 10:35:46 -0500 (Wed, 10 Feb 2010)
New Revision: 12919

Modified:
   trunk/qgis/src/plugins/grass/qgsgrassshell.cpp
   trunk/qgis/src/providers/grass/qgsgrass.cpp
   trunk/qgis/src/providers/grass/qgsgrass.h
Log:
reset GRASS_GUI in term

Modified: trunk/qgis/src/plugins/grass/qgsgrassshell.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassshell.cpp	2010-02-10 15:14:07 UTC (rev 12918)
+++ trunk/qgis/src/plugins/grass/qgsgrassshell.cpp	2010-02-10 15:35:46 UTC (rev 12919)
@@ -17,6 +17,7 @@
 #include <QShortcut>
 #include <QKeySequence>
 
+#include "qgslogger.h"
 #include "qtermwidget/qtermwidget.h"
 #include "qgsgrass.h"
 
@@ -53,6 +54,29 @@
 
   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 );
 }
 

Modified: trunk/qgis/src/providers/grass/qgsgrass.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrass.cpp	2010-02-10 15:14:07 UTC (rev 12918)
+++ trunk/qgis/src/providers/grass/qgsgrass.cpp	2010-02-10 15:35:46 UTC (rev 12919)
@@ -1242,3 +1242,17 @@
 {
   return mMapsetLock;
 }
+
+QString GRASS_EXPORT QgsGrass::gisrcFilePath()
+{
+  if ( mGisrc.isEmpty() )
+  {
+    // Started from GRASS shell
+    if ( getenv( "GISRC" ) )
+    {
+      return QString ( getenv( "GISRC" ) );
+    }
+  }
+  return mGisrc;
+}
+

Modified: trunk/qgis/src/providers/grass/qgsgrass.h
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrass.h	2010-02-10 15:14:07 UTC (rev 12918)
+++ trunk/qgis/src/providers/grass/qgsgrass.h	2010-02-10 15:35:46 UTC (rev 12919)
@@ -160,6 +160,9 @@
     // ! Get the lock file
     static GRASS_EXPORT QString lockFilePath();
 
+    // ! Get current gisrc path
+    static QString gisrcFilePath();
+
     // ! Run a GRASS module in any gisdbase/location
     static GRASS_EXPORT QByteArray runModule( QString gisdbase, QString location, QString module, QStringList arguments );
 



More information about the QGIS-commit mailing list