[rkward-cvs] rkward/rkward/rbackend rinterface.cpp, 1.51, 1.52 rinterface.h, 1.23, 1.24 rthread.cpp, 1.42, 1.43

Thomas Friedrichsmeier tfry at users.sourceforge.net
Thu Sep 14 20:29:20 UTC 2006


Update of /cvsroot/rkward/rkward/rkward/rbackend
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1941/rkward/rbackend

Modified Files:
	rinterface.cpp rinterface.h rthread.cpp 
Log Message:
Don't include rthread.h everywhere
Make it less dangerous to press cancel in a readline() call. Unfortunately there may still be problems in rare cases.

Index: rinterface.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rinterface.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** rinterface.cpp	10 Sep 2006 23:45:40 -0000	1.51
--- rinterface.cpp	14 Sep 2006 20:29:18 -0000	1.52
***************
*** 112,115 ****
--- 112,119 ----
  }
  
+ RCommand *RInterface::runningCommand () {
+ 	 return r_thread->current_command;
+ }
+ 
  void RInterface::customEvent (QCustomEvent *e) {
  	RK_TRACE (RBACKEND);
***************
*** 333,339 ****
  		KMessageBox::information (0, QString (*(args->chars_a)), i18n ("Message from the R backend"));
  	} else if (type == RCallbackArgs::RReadConsole) {
  		bool ok;
  		QRegExpValidator *dummy = new QRegExpValidator (QRegExp (".*"), 0);		// needed to allow empty strings in KInputDialog::getText
! 		QString res = KInputDialog::getText (i18n ("R backend requests information"), QString (*(args->chars_a)), QString::null, &ok, 0, 0, dummy);
  		delete dummy;
  		res = res.left (args->int_a - 2) + "\n";
--- 337,345 ----
  		KMessageBox::information (0, QString (*(args->chars_a)), i18n ("Message from the R backend"));
  	} else if (type == RCallbackArgs::RReadConsole) {
+ 		QString question = *(args->chars_a);
+ 
  		bool ok;
  		QRegExpValidator *dummy = new QRegExpValidator (QRegExp (".*"), 0);		// needed to allow empty strings in KInputDialog::getText
! 		QString res = KInputDialog::getText (i18n ("R backend requests information"), question, QString::null, &ok, 0, 0, dummy);
  		delete dummy;
  		res = res.left (args->int_a - 2) + "\n";

Index: rthread.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rthread.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** rthread.cpp	11 Sep 2006 09:52:40 -0000	1.42
--- rthread.cpp	14 Sep 2006 20:29:18 -0000	1.43
***************
*** 354,368 ****
  	
  	bool done = false;
! 	while (!done) {
! 		// callback not done yet? Sleep for a while
! 		msleep (10);
! 
! 		MUTEX_LOCK;
! 		processX11Events ();
  
! 		if (args->done) {
! 			done = true;		// safe to access only while the mutex is locked
  		}
- 		MUTEX_UNLOCK;
  	}
  }
--- 354,369 ----
  	
  	bool done = false;
! 	while (!(done || (locked & Cancel))) {	// what's with that lock? If the current command is cancelled, while we're in this loop, we must not lock the mutex. We may get long-jumped out of the loop before we get a chance to unlock.
! 		msleep (10); // callback not done yet? Sleep for a while
  
! 		if (!locked) {
! 			MUTEX_LOCK;
! 			processX11Events ();
! 	
! 			if (args->done) {
! 				done = true;		// safe to access only while the mutex is locked
! 			}
! 			MUTEX_UNLOCK;
  		}
  	}
  }

Index: rinterface.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rinterface.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** rinterface.h	1 Sep 2006 15:38:17 -0000	1.23
--- rinterface.h	14 Sep 2006 20:29:18 -0000	1.24
***************
*** 22,26 ****
  #include <qmutex.h>
  
! #include "rthread.h"
  
  //#define DEBUG_MUTEX
--- 22,26 ----
  #include <qmutex.h>
  
! #include "rcommand.h"
  
  //#define DEBUG_MUTEX
***************
*** 38,41 ****
--- 38,44 ----
  struct RCallbackArgs;
  class QTimer;
+ class RThread;
+ class RCommandReceiver;
+ struct REvalRequest;
  
  /** This class provides the main interface to the R-processor.
***************
*** 83,87 ****
  
  /** returns the command currently running in the thread. Be careful when using the returned pointer! */
! 	RCommand *runningCommand () { return r_thread->current_command; };
  public slots:
  /** called periodically to flush output buffer in RThread */
--- 86,90 ----
  
  /** returns the command currently running in the thread. Be careful when using the returned pointer! */
! 	RCommand *runningCommand ();
  public slots:
  /** called periodically to flush output buffer in RThread */





More information about the rkward-tracker mailing list