[rkward-cvs] rkward/rkward/rbackend rinterface.cpp, 1.52, 1.53 rinterface.h, 1.24, 1.25 rthread.cpp, 1.43, 1.44

Thomas Friedrichsmeier tfry at users.sourceforge.net
Fri Sep 15 10:50:50 UTC 2006


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

Modified Files:
	rinterface.cpp rinterface.h rthread.cpp 
Log Message:
Some (small) progress on cancelling during callbacks

Index: rinterface.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rinterface.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** rinterface.h	14 Sep 2006 20:29:18 -0000	1.24
--- rinterface.h	15 Sep 2006 10:50:48 -0000	1.25
***************
*** 24,28 ****
  #include "rcommand.h"
  
! //#define DEBUG_MUTEX
  #ifdef DEBUG_MUTEX
  #define MUTEX_LOCK qDebug ("mutex locks: %d, locked in %s, %s, %d", ++RInterface::mutex_counter, __FILE__, __FUNCTION__, __LINE__); RInterface::mutex.lock ();
--- 24,28 ----
  #include "rcommand.h"
  
! #define DEBUG_MUTEX
  #ifdef DEBUG_MUTEX
  #define MUTEX_LOCK qDebug ("mutex locks: %d, locked in %s, %s, %d", ++RInterface::mutex_counter, __FILE__, __FUNCTION__, __LINE__); RInterface::mutex.lock ();

Index: rinterface.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rinterface.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** rinterface.cpp	14 Sep 2006 20:29:18 -0000	1.52
--- rinterface.cpp	15 Sep 2006 10:50:48 -0000	1.53
***************
*** 346,350 ****
  		qstrcpy (*(args->chars_b), res.latin1 ());
  
! 		if (!ok) cancelCommand (runningCommand ());
  	} else if ((type == RCallbackArgs::RShowFiles) || (type == RCallbackArgs::REditFiles)) {
  		if ((type == RCallbackArgs::RShowFiles) && (QString (*(args->chars_d)) == "rkwardhtml")) {
--- 346,354 ----
  		qstrcpy (*(args->chars_b), res.latin1 ());
  
! 		if (!ok) {
! 			args->done = true;		// need to do this at once. Else we risk getting stuck in the standard callback event loop
! 			cancelCommand (runningCommand ());
! 			return;
! 		}
  	} else if ((type == RCallbackArgs::RShowFiles) || (type == RCallbackArgs::REditFiles)) {
  		if ((type == RCallbackArgs::RShowFiles) && (QString (*(args->chars_d)) == "rkwardhtml")) {
***************
*** 380,386 ****
  	}
  
- 	MUTEX_LOCK;
  	args->done = true;
- 	MUTEX_UNLOCK;
  }
  
--- 384,388 ----

Index: rthread.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rthread.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** rthread.cpp	14 Sep 2006 20:29:18 -0000	1.43
--- rthread.cpp	15 Sep 2006 10:50:48 -0000	1.44
***************
*** 353,367 ****
  	qApp->postEvent (RKGlobals::rInterface (), event);
  	
! 	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;
  		}
--- 353,363 ----
  	qApp->postEvent (RKGlobals::rInterface (), event);
  	
! 	bool *done = &(args->done);
! 	while (!(*done)) {
  		msleep (10); // callback not done yet? Sleep for a while
  
! 		if (!locked) {			// what's with that lock? If the current command is cancelled, while we're in this loop, we must not lock the mutex and/or call anything in R. We may get long-jumped out of the loop before we get a chance to unlock
  			MUTEX_LOCK;
! 			if (!locked) processX11Events ();
  			MUTEX_UNLOCK;
  		}





More information about the rkward-tracker mailing list