[rkward-cvs] SF.net SVN: rkward:[3988] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sat Oct 22 13:52:25 UTC 2011


Revision: 3988
          http://rkward.svn.sourceforge.net/rkward/?rev=3988&view=rev
Author:   tfry
Date:     2011-10-22 13:52:25 +0000 (Sat, 22 Oct 2011)
Log Message:
-----------
Allow to cancel debugger context using the regular cancelation mechanism

Modified Paths:
--------------
    trunk/rkward/rkward/agents/rkdebughandler.cpp
    trunk/rkward/rkward/agents/rkdebughandler.h
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/windows/rkdebugconsole.cpp

Modified: trunk/rkward/rkward/agents/rkdebughandler.cpp
===================================================================
--- trunk/rkward/rkward/agents/rkdebughandler.cpp	2011-10-22 09:09:18 UTC (rev 3987)
+++ trunk/rkward/rkward/agents/rkdebughandler.cpp	2011-10-22 13:52:25 UTC (rev 3988)
@@ -28,6 +28,7 @@
 
 	_state = NotInDebugger;
 	_request = 0;
+	_command = 0;
 	_instance = this;
 }
 
@@ -38,6 +39,7 @@
 void RKDebugHandler::debugCall (RBackendRequest *request, RCommand *command) {
 	RK_TRACE (APP);
 
+	_command = command;
 	_request = request;
 	if (command) _output_context = command->fullOutput ();
 	else _output_context.clear ();
@@ -52,6 +54,13 @@
 	newDebugState ();
 }
 
+void RKDebugHandler::sendCancel () {
+	RK_TRACE (APP);
+
+	RK_ASSERT (_request);
+	submitDebugString ("Q\n");
+}
+
 void RKDebugHandler::submitDebugString (const QString &command) {
 	RK_TRACE (APP);
 
@@ -64,6 +73,7 @@
 
 	RKRBackendProtocolFrontend::setRequestCompleted (_request);
 
+	_command = 0;
 	_state = InDebugRun;
 	newDebugState ();
 }
@@ -71,10 +81,10 @@
 void RKDebugHandler::endDebug () {
 	RK_TRACE (APP);
 
+	_command = 0;
 	_request = 0;
 	_state = NotInDebugger;
 	newDebugState ();
 }
 
 #include "rkdebughandler.moc"
-

Modified: trunk/rkward/rkward/agents/rkdebughandler.h
===================================================================
--- trunk/rkward/rkward/agents/rkdebughandler.h	2011-10-22 09:09:18 UTC (rev 3987)
+++ trunk/rkward/rkward/agents/rkdebughandler.h	2011-10-22 13:52:25 UTC (rev 3988)
@@ -35,6 +35,7 @@
 
 	void debugCall (RBackendRequest *request, RCommand *command);
 	void submitDebugString (const QString &command);
+	void sendCancel ();
 	void endDebug ();
 
 	enum DebugState {
@@ -50,9 +51,11 @@
 	QStringList environments () const { return _environments; };
 	QStringList locals () const { return _locals; };
 	QString debugPrompt () const { return _prompt; };
+	RCommand *command () const { return _command; };
 signals:
 	void newDebugState ();
 private:
+	RCommand *_command;
 	QStringList _calls, _functions, _environments, _locals;
 	QString _prompt, _output_context;
 	DebugState _state;

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2011-10-22 09:09:18 UTC (rev 3987)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2011-10-22 13:52:25 UTC (rev 3988)
@@ -475,7 +475,11 @@
 	if (!(command->type () & RCommand::Sync)) {
 		command->status |= RCommand::Canceled;
 		if (command->type () && RCommand::Running) {
-			RKRBackendProtocolFrontend::instance ()->interruptCommand (command->id ());
+			if ((RKDebugHandler::instance ()->state () == RKDebugHandler::InDebugPrompt) && (command == RKDebugHandler::instance ()->command ())) {
+				RKDebugHandler::instance ()->sendCancel ();
+			} else {
+				RKRBackendProtocolFrontend::instance ()->interruptCommand (command->id ());
+			}
 		}
 		RCommandStackModel::getModel ()->itemChange (command);
 	} else {

Modified: trunk/rkward/rkward/windows/rkdebugconsole.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkdebugconsole.cpp	2011-10-22 09:09:18 UTC (rev 3987)
+++ trunk/rkward/rkward/windows/rkdebugconsole.cpp	2011-10-22 13:52:25 UTC (rev 3988)
@@ -129,7 +129,7 @@
 void RKDebugConsole::cancelButtonClicked () {
 	RK_TRACE (APP);
 
-	sendReply ("Q\n");
+	RKDebugHandler::instance ()->sendCancel ();
 }
 
 void RKDebugConsole::sendReply (const QString &reply) {

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rkward-tracker mailing list