Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
reset GRASS_GUI in term
git-svn-id: http://svn.osgeo.org/qgis/trunk@12919 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Feb 10, 2010
1 parent 84ec0ae commit 8cd99cd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/plugins/grass/qgsgrassshell.cpp
Expand Up @@ -17,6 +17,7 @@
#include <QShortcut>
#include <QKeySequence>

#include "qgslogger.h"
#include "qtermwidget/qtermwidget.h"
#include "qgsgrass.h"

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

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 );
}

Expand Down
14 changes: 14 additions & 0 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -1242,3 +1242,17 @@ QString GRASS_EXPORT QgsGrass::lockFilePath()
{
return mMapsetLock;
}

QString GRASS_EXPORT QgsGrass::gisrcFilePath()
{
if ( mGisrc.isEmpty() )
{
// Started from GRASS shell
if ( getenv( "GISRC" ) )
{
return QString ( getenv( "GISRC" ) );
}
}
return mGisrc;
}

3 changes: 3 additions & 0 deletions src/providers/grass/qgsgrass.h
Expand Up @@ -160,6 +160,9 @@ class QgsGrass
// ! 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 );

Expand Down

0 comments on commit 8cd99cd

Please sign in to comment.