Skip to content

Commit 8cd99cd

Browse files
author
rblazek
committedFeb 10, 2010
reset GRASS_GUI in term
git-svn-id: http://svn.osgeo.org/qgis/trunk@12919 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 84ec0ae commit 8cd99cd

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
 

‎src/plugins/grass/qgsgrassshell.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <QShortcut>
1818
#include <QKeySequence>
1919

20+
#include "qgslogger.h"
2021
#include "qtermwidget/qtermwidget.h"
2122
#include "qgsgrass.h"
2223

@@ -53,6 +54,29 @@ QgsGrassShell::QgsGrassShell( QgsGrassTools *tools, QTabWidget *parent, const ch
5354

5455
mTerminal->setSize( 80, 25 );
5556
mTerminal->startShellProgram();
57+
// using -text option GRASS_GUI is owerridden so we have to reset it
58+
QgsDebugMsg ( "gisrc = " + QgsGrass::gisrcFilePath() );
59+
QFile in( QgsGrass::gisrcFilePath() );
60+
if ( in.open( QIODevice::ReadOnly ) )
61+
{
62+
char buf[1000];
63+
QString oldGui;
64+
while ( in.readLine( buf, 1000 ) != -1 )
65+
{
66+
QString line = buf;
67+
QStringList kv = line.split ( ':' );
68+
if ( kv.length() == 2 && kv.at(0) == "GRASS_GUI" )
69+
{
70+
oldGui = kv.at(1).trimmed ();
71+
break;
72+
}
73+
}
74+
if ( ! oldGui.isEmpty() )
75+
{
76+
QString cmd = QString("g.gisenv set=GRASS_GUI=") + oldGui + "\n";
77+
mTerminal->sendText( cmd );
78+
}
79+
}
5680
mTerminal->setFocus( Qt::MouseFocusReason );
5781
}
5882

‎src/providers/grass/qgsgrass.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,3 +1242,17 @@ QString GRASS_EXPORT QgsGrass::lockFilePath()
12421242
{
12431243
return mMapsetLock;
12441244
}
1245+
1246+
QString GRASS_EXPORT QgsGrass::gisrcFilePath()
1247+
{
1248+
if ( mGisrc.isEmpty() )
1249+
{
1250+
// Started from GRASS shell
1251+
if ( getenv( "GISRC" ) )
1252+
{
1253+
return QString ( getenv( "GISRC" ) );
1254+
}
1255+
}
1256+
return mGisrc;
1257+
}
1258+

‎src/providers/grass/qgsgrass.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ class QgsGrass
160160
// ! Get the lock file
161161
static GRASS_EXPORT QString lockFilePath();
162162

163+
// ! Get current gisrc path
164+
static QString gisrcFilePath();
165+
163166
// ! Run a GRASS module in any gisdbase/location
164167
static GRASS_EXPORT QByteArray runModule( QString gisdbase, QString location, QString module, QStringList arguments );
165168

0 commit comments

Comments
 (0)
Please sign in to comment.