@@ -46,38 +46,18 @@ QgsGrassShell::QgsGrassShell( QgsGrassTools *tools, QTabWidget *parent, const ch
46
46
connect ( copyShortcut, SIGNAL ( activated () ), mTerminal , SLOT ( copyClipboard () ) );
47
47
48
48
// TODO: find a better way to manage the lockfile.
49
+ // 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
50
+ /*
49
51
mLockFilename = QgsGrass::lockFilePath();
50
52
QFile::remove( mLockFilename + ".qgis" );
51
53
if ( !QFile::rename( mLockFilename, mLockFilename + ".qgis" ) )
52
54
{
53
55
QMessageBox::warning( this, tr( "Warning" ), tr( "Cannot rename the lock file %1" ).arg( mLockFilename ) );
54
56
}
57
+ */
55
58
56
59
mTerminal ->setSize ( 80 , 25 );
57
60
mTerminal ->startShellProgram ();
58
- // using -text option GRASS_GUI is owerridden so we have to reset it
59
- QgsDebugMsg ( " gisrc = " + QgsGrass::gisrcFilePath () );
60
- QFile in ( QgsGrass::gisrcFilePath () );
61
- if ( in.open ( QIODevice::ReadOnly ) )
62
- {
63
- char buf[1000 ];
64
- QString oldGui;
65
- while ( in.readLine ( buf, 1000 ) != -1 )
66
- {
67
- QString line = buf;
68
- QStringList kv = line.split ( ' :' );
69
- if ( kv.length () == 2 && kv.at (0 ) == " GRASS_GUI" )
70
- {
71
- oldGui = kv.at (1 ).trimmed ();
72
- break ;
73
- }
74
- }
75
- if ( ! oldGui.isEmpty () )
76
- {
77
- QString cmd = QString (" g.gisenv set=GRASS_GUI=" ) + oldGui + " \n " ;
78
- mTerminal ->sendText ( cmd );
79
- }
80
- }
81
61
mTerminal ->setFocus ( Qt::MouseFocusReason );
82
62
}
83
63
@@ -91,11 +71,13 @@ void QgsGrassShell::closeShell()
91
71
mTabWidget ->removeTab ( index );
92
72
93
73
// TODO: find a better way to manage the lockfile.
74
+ // No locking should be done here, see above
75
+ /*
94
76
if ( !QFile::rename( mLockFilename + ".qgis", mLockFilename ) )
95
77
{
96
78
QMessageBox::warning( this, tr( "Warning" ), tr( "Cannot rename the lock file %1" ).arg( mLockFilename ) );
97
79
}
98
-
80
+ */
99
81
this ->deleteLater ();
100
82
}
101
83
@@ -104,18 +86,22 @@ void QgsGrassShell::initTerminal( QTermWidget *terminal )
104
86
QStringList env ( " " );
105
87
QStringList args ( " " );
106
88
107
- QString shellProgram = QString ( " %1/etc/Init.sh" ).arg ( ::getenv ( " GISBASE" ) );
89
+ // 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
90
+ // QString shellProgram = QString( "%1/etc/Init.sh" ).arg( ::getenv( "GISBASE" ) );
108
91
109
- terminal->setShellProgram ( shellProgram );
92
+ // terminal->setShellProgram( shellProgram );
110
93
env << " TERM=vt100" ;
111
94
env << " GISRC_MODE_MEMORY" ;
112
- // 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
95
+ // TODO: we should check if these environment variable were set by user before QGIS was started
113
96
env << " GRASS_HTML_BROWSER=" + QgsApplication::pkgDataPath () + " /grass/bin/qgis.g.browser" ;
97
+ env << " GRASS_WISH=wish" ;
98
+ env << " GRASS_TCLSH=tclsh" ;
99
+ env << " GRASS_PYTHON=python" ;
114
100
115
- args << " -text" ;
116
- args << QString ( " %1/%2/%3" ).arg ( QgsGrass::getDefaultGisdbase () ).arg ( QgsGrass::getDefaultLocation () ).arg ( QgsGrass::getDefaultMapset () );
101
+ // args << "-text";
102
+ // args << QString( "%1/%2/%3" ).arg( QgsGrass::getDefaultGisdbase() ).arg( QgsGrass::getDefaultLocation() ).arg( QgsGrass::getDefaultMapset() );
117
103
118
- terminal->setArgs ( args );
104
+ // terminal->setArgs( args );
119
105
terminal->setEnvironment ( env );
120
106
121
107
// Look & Feel
0 commit comments