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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Oct 11 21:42:40 UTC 2006


Revision: 851
          http://svn.sourceforge.net/rkward/?rev=851&view=rev
Author:   tfry
Date:     2006-10-11 14:42:29 -0700 (Wed, 11 Oct 2006)

Log Message:
-----------
Yet another fix to cancelling during readline () calls. Seems to work well, finally

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/TODO
    trunk/rkward/rkward/dialogs/rkreadlinedialog.cpp
    trunk/rkward/rkward/rbackend/rembedinternal.cpp
    trunk/rkward/rkward/rbackend/rembedinternal.h
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rthread.cpp
    trunk/rkward/rkward/rbackend/rthread.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2006-10-11 21:14:49 UTC (rev 850)
+++ trunk/rkward/ChangeLog	2006-10-11 21:42:29 UTC (rev 851)
@@ -1,3 +1,4 @@
+- another fix to cancelling during readline () calls
 - invalid values are stored in a separate attribute instead of changing the storage mode back and forth -> TODO
 - storage mode for RKWard meta data was changed -> TODO
 - RMB option to search help on objects from packages in object browser

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2006-10-11 21:14:49 UTC (rev 850)
+++ trunk/rkward/TODO	2006-10-11 21:42:29 UTC (rev 851)
@@ -8,10 +8,6 @@
 Bugs:
 	- There seems to be a race condition at startup, leading to a crash in doPostInit () in rkward.cpp. (Un-)Fortunately it triggers only rarely, and I have not yet figured out, when it occurs. Is this still the case? I've fixed one potential race condition a while ago, and have not seen this crash in a while (2006/09/27)
 	- "cannot create html package index" when installing package as a regular user (due to R.home ("doc") not writable)
-	- produce many readline calls (e.g. "for (i in 1:10) readline()") repeatedly and cancel all of them.
-		- Sometimes only the readine is interrupted, sometimes the whole command (might be R's fault? But works fine in plain R)
-		- Occasionally this seems to leave R in a bad (semi-crashed) state
-		- Can't we just return 0 from RReadConsole? We do, but it doesn't help. Maybe in this case we need to send the SIGINT from within the callback (in the backend thread)?
 	- There is definitely a memory leak in handling output!
 		- Produce lots and lots of output -> watch mem usage grow
 		- Probably the RKConsole is to blame (run outside console -> no significant increase)

Modified: trunk/rkward/rkward/dialogs/rkreadlinedialog.cpp
===================================================================
--- trunk/rkward/rkward/dialogs/rkreadlinedialog.cpp	2006-10-11 21:14:49 UTC (rev 850)
+++ trunk/rkward/rkward/dialogs/rkreadlinedialog.cpp	2006-10-11 21:42:29 UTC (rev 851)
@@ -78,5 +78,5 @@
 	*result = dialog->input->text ();
 	delete dialog;
 
-	return (res != KDialogBase::Cancel);
+	return (res != QDialog::Rejected);
 }

Modified: trunk/rkward/rkward/rbackend/rembedinternal.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.cpp	2006-10-11 21:14:49 UTC (rev 850)
+++ trunk/rkward/rkward/rbackend/rembedinternal.cpp	2006-10-11 21:42:29 UTC (rev 851)
@@ -101,6 +101,10 @@
 
 	REmbedInternal::this_pointer->handleStandardCallback (&args);
 // default implementation seems to return 1 on success, 0 on failure, contrary to some documentation. see unix/std-sys.c
+	if (!(args.int_c)) {
+		REmbedInternal::this_pointer->currentCommandWasCancelled ();
+		Rf_onintr ();
+	}
 	if (buf && args.int_c) return 1;
 	return 0;
 }

Modified: trunk/rkward/rkward/rbackend/rembedinternal.h
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.h	2006-10-11 21:14:49 UTC (rev 850)
+++ trunk/rkward/rkward/rbackend/rembedinternal.h	2006-10-11 21:42:29 UTC (rev 851)
@@ -148,6 +148,8 @@
 @see RCallbackArgs @see RCallbackType */
 	virtual void handleStandardCallback (RCallbackArgs *args) = 0;
 
+	virtual void currentCommandWasCancelled () = 0;
+
 	bool registerFunctions (const char *library_path);
 /** only one instance of this class may be around. This pointer keeps the reference to it, for interfacing to from C to C++ */
 	static REmbedInternal *this_pointer;

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2006-10-11 21:14:49 UTC (rev 850)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2006-10-11 21:42:29 UTC (rev 851)
@@ -368,12 +368,7 @@
 		result = result.left (args->int_a - 2) + '\n';
 		qstrcpy (*(args->chars_b), result.local8Bit ());
 
-		if (!ok) {
-			args->int_c = 0;
-			args->done = true;		// need to do this at once. Else we risk getting stuck in the standard callback event loop
-			cancelCommand (runningCommand ());
-			return;
-		}
+		if (!ok) args->int_c = 0;	// will be cancelled deep inside REmbedInternal, where it's safest
 	} else if ((type == RCallbackArgs::RShowFiles) || (type == RCallbackArgs::REditFiles)) {
 		if ((type == RCallbackArgs::RShowFiles) && (QString (*(args->chars_d)) == "rkwardhtml")) {
 			// not to worry, just some help file to display

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2006-10-11 21:14:49 UTC (rev 850)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2006-10-11 21:42:29 UTC (rev 851)
@@ -390,6 +390,13 @@
 	RK_DO (qDebug ("standard callback done"), RBACKEND, DL_DEBUG);
 }
 
+void RThread::currentCommandWasCancelled () {
+	RK_TRACE (RBACKEND);
+
+	RK_ASSERT (current_command);
+	current_command->status |= RCommand::Canceled;
+}
+
 int RThread::initialize () {
 	RK_TRACE (RBACKEND);
 

Modified: trunk/rkward/rkward/rbackend/rthread.h
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.h	2006-10-11 21:14:49 UTC (rev 850)
+++ trunk/rkward/rkward/rbackend/rthread.h	2006-10-11 21:42:29 UTC (rev 851)
@@ -141,6 +141,8 @@
 @see REmbedInternal::handleStandardCallback () */
 	void handleStandardCallback (RCallbackArgs *args);
 
+	void currentCommandWasCancelled ();
+
 /** The command currently being executed. This is used from RInterface::cancelCommand to find out, whether the command to be cancelled is
 already/still running. */
 	RCommand *current_command;


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