@@ -56,6 +56,7 @@ QgsGrassShell::QgsGrassShell ( QgsGrassTools *tools,
56
56
QDialog(parent), QgsGrassShellBase(), mTools(tools)
57
57
{
58
58
mValid = false ;
59
+ mSkipLines = 2 ;
59
60
60
61
#ifdef WIN32
61
62
QMessageBox::warning ( 0 , " Warning" ,
@@ -236,6 +237,12 @@ QgsGrassShell::QgsGrassShell ( QgsGrassTools *tools,
236
237
mTabStop [i*8 ] = true ;
237
238
}
238
239
240
+ // Set trap to write history on SIGUSR1
241
+ // QString trap = "trap 'history -w' SIGUSR1\015\012";
242
+ QString trap = " trap 'history -w' SIGUSR1\015 " ;
243
+ write ( mFdMaster , trap.ascii (), trap.length ());
244
+ mText ->clear ();
245
+
239
246
resizeTerminal ();
240
247
mValid = true ;
241
248
#endif // !WIN32
@@ -247,12 +254,10 @@ QgsGrassShell::~QgsGrassShell()
247
254
std::cerr << " QgsGrassShell::~QgsGrassShell()" << std::endl;
248
255
#endif
249
256
250
- // TODO: find signal to write history before exit
251
- // instead of sending 'exit'
252
-
253
- write ( mFdMaster , " exit\015\012 " , 6 );
254
-
255
257
#ifndef WIN32
258
+ // This was old trick to write history
259
+ /*
260
+ write( mFdMaster, "exit\015\012", 6);
256
261
while ( 1 )
257
262
{
258
263
readStdout(0);
@@ -265,15 +270,20 @@ QgsGrassShell::~QgsGrassShell()
265
270
t.tv_nsec = 10000000; // 0.01 s
266
271
nanosleep ( &t, &r );
267
272
}
268
- #endif
273
+ */
274
+
275
+ // Write history
276
+ if ( kill (mPid ,SIGUSR1) == -1 )
277
+ {
278
+ std::cerr << " cannot write history (signal SIGUSR1 to pid = " << mPid << " )" << std::endl;
279
+ }
269
280
270
- /*
271
281
std::cerr << " kill shell pid = " << mPid << std::endl;
272
282
if ( kill (mPid ,SIGTERM ) == -1 )
273
283
{
274
284
std::cerr << " cannot kill shell pid = " << mPid << std::endl;
275
285
}
276
- */
286
+ # endif
277
287
}
278
288
279
289
void QgsGrassShell::keyPressEvent ( QKeyEvent * e )
@@ -810,6 +820,11 @@ void QgsGrassShell::insert ( QString s )
810
820
811
821
void QgsGrassShell::newLine ()
812
822
{
823
+ if ( mSkipLines > 0 )
824
+ {
825
+ mText ->clear ();
826
+ mSkipLines --;
827
+ }
813
828
if ( mNewLine )
814
829
{
815
830
mText ->setTextFormat (Qt::PlainText);
0 commit comments