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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Jan 25 00:03:49 UTC 2008


Revision: 2346
          http://rkward.svn.sourceforge.net/rkward/?rev=2346&view=rev
Author:   tfry
Date:     2008-01-24 16:03:49 -0800 (Thu, 24 Jan 2008)

Log Message:
-----------
Somewhat better handling of the event loop for R >= 2.3.x (and probably we should drop support for earlier versions, anyway)

Modified Paths:
--------------
    trunk/rkward/rkward/dialogs/rkloadlibsdialog.cpp
    trunk/rkward/rkward/rbackend/rembedinternal.cpp
    trunk/rkward/rkward/rbackend/rthread.cpp

Modified: trunk/rkward/rkward/dialogs/rkloadlibsdialog.cpp
===================================================================
--- trunk/rkward/rkward/dialogs/rkloadlibsdialog.cpp	2008-01-23 15:42:07 UTC (rev 2345)
+++ trunk/rkward/rkward/dialogs/rkloadlibsdialog.cpp	2008-01-25 00:03:49 UTC (rev 2346)
@@ -2,7 +2,7 @@
                           rkloadlibsdialog  -  description
                              -------------------
     begin                : Mon Sep 6 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2008 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -320,6 +320,7 @@
 
 void LoadUnloadWidget::rCommandDone (RCommand *command) {
 	RK_TRACE (DIALOGS);
+	if (command->failed ()) return;
 	if (command->getFlags () == GET_INSTALLED_PACKAGES) {
 		RK_ASSERT (command->getDataLength () == 4);
 

Modified: trunk/rkward/rkward/rbackend/rembedinternal.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.cpp	2008-01-23 15:42:07 UTC (rev 2345)
+++ trunk/rkward/rkward/rbackend/rembedinternal.cpp	2008-01-25 00:03:49 UTC (rev 2346)
@@ -2,7 +2,7 @@
                           rembedinternal  -  description
                              -------------------
     begin                : Sun Jul 25 2004
-    copyright            : (C) 2004, 2005, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2005, 2006, 2007, 2008 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -117,6 +117,7 @@
 extern uintptr_t R_CStackLimit;
 extern uintptr_t R_CStackStart;
 extern Rboolean R_Interactive;
+#include "R_ext/eventloop.h"
 #endif
 #ifndef USE_R_REPLDLLDO1
 extern Rboolean R_Visible;
@@ -427,6 +428,16 @@
 static int timeout_counter = 0;
 
 void processX11EventsWorker (void *) {
+#ifdef R_2_3
+// this basically copied from R's unix/sys-std.c (Rstd_ReadConsole)
+// we stop processing, if there are more than 10 events
+	for (;;) {
+		fd_set *what;
+		what = R_checkActivity(R_wait_usec > 0 ? R_wait_usec : 50, 1);
+		R_runHandlers(R_InputHandlers, what);
+		if (what == NULL) break;
+	}
+#else
 /* what we do here is walk the list of objects, that have told R, they're listening for events.
 We figure out which ones look for X11-events and tell those to do their stuff (regardless of whether events actually occurred) */
 	extern InputHandler *R_InputHandlers;
@@ -448,6 +459,7 @@
 		if (R_timeout_handler) R_timeout_handler ();
 		timeout_counter = 0;
 	}
+#endif
 }
 
 void REmbedInternal::processX11Events () {

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2008-01-23 15:42:07 UTC (rev 2345)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2008-01-25 00:03:49 UTC (rev 2346)
@@ -2,7 +2,7 @@
                           rthread  -  description
                              -------------------
     begin                : Mon Aug 2 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2008 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -244,7 +244,9 @@
 		RK_DO (qDebug ("done running command"), RBACKEND, DL_DEBUG);
 		all_current_commands.pop_back();
 	} else {
-		if (command->type () & RCommand::QuitCommand) {
+		if (command->status & RCommand::Canceled) {
+			command->status |= RCommand::Failed;
+		} else if (command->type () & RCommand::QuitCommand) {
 			killed = true;
 			MUTEX_UNLOCK;
 			shutdown (false);
@@ -418,15 +420,17 @@
 			}
 
 			current_command = reply_stack->currentCommand ();
-			
 			if (current_command) {
 				// mutex will be unlocked inside
 				bool object_update_forced = (current_command->type () & RCommand::ObjectListUpdate);
 				doCommand (current_command);
+				if (!(locked || killed)) processX11Events ();
+				else msleep (100);
 				if (object_update_forced) checkObjectUpdatesNeeded (true);
-				processX11Events ();
 				reply_stack->pop ();
 				notifyCommandDone (current_command);	// command may be deleted after this
+			} else {
+				msleep (10);
 			}
 		}
 


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