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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Jun 25 06:08:39 UTC 2010


Revision: 2902
          http://rkward.svn.sourceforge.net/rkward/?rev=2902&view=rev
Author:   tfry
Date:     2010-06-25 06:08:38 +0000 (Fri, 25 Jun 2010)

Log Message:
-----------
New solution for the dev.off()-bug: Close the window in RKWard and sync with X server before calling the real dev.off()

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
    trunk/rkward/rkward/windows/rkwindowcatcher.cpp
    trunk/rkward/rkward/windows/rkwindowcatcher.h

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2010-06-24 15:14:46 UTC (rev 2901)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2010-06-25 06:08:38 UTC (rev 2902)
@@ -385,9 +385,13 @@
 			MUTEX_UNLOCK;
 		}
 	} else if (call == "updateDeviceHistory") {
-		if (request->call.count () >= 3) {
+		if (request->call.count () >= 2) {
 			window_catcher->updateHistory (request->call.mid (1));
 		}
+	} else if (call == "killDevice") {
+		if (request->call.count () >= 2) {
+			window_catcher->killDevice (request->call[1].toInt ());
+		}
 #endif // DISABLE_RKWINDOWCATCHER
 	} else if (call == "wdChange") {
 		RKWardMainWindow::getMain ()->updateCWD ();

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R	2010-06-24 15:14:46 UTC (rev 2901)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R	2010-06-25 06:08:38 UTC (rev 2902)
@@ -77,36 +77,24 @@
 formals (plot.new) <- formals (graphics::plot.new)
 .rk.plot.new.default <- graphics::plot.new
 
-# Wait time between two dev.off () calls for the renegade devices;
-# users can change it by calling the function
-.rk.renegade.devices.kill.time <- 0.1
-".rk.set.renegade.kill.time" <- function (x = 0.1) .rk.renegade.devices.kill.time <<- x
-
 "dev.off" <- function (which = dev.cur ())
 {
 	.is.inter <- dev.interactive ()
 	if (.is.inter) { 
 		# Why use 'which'? There is a which ()!!
 		if (!(which %in% .rk.preview.devices)) rk.record.plot$onDelDevice (deviceId = which)
-		
-		ldevs.before <- dev.list ()
+
+		# see http://thread.gmane.org/gmane.comp.statistics.rkward.devel/802
+		.rk.do.call ("killDevice", as.character (which))
 	}
+
+	ret <- eval (body (.rk.dev.off.default))
 	
-	eval (body (.rk.dev.off.default))
-	.ret.value <- .Last.value
-	
 	if (.is.inter) {
-		renegade.devices <- setdiff (dev.list (), ldevs.before)
-		if (!is.null (renegade.devices) && length (renegade.devices) > 0)
-			sapply (X = renegade.devices, 
-				FUN = function (x) {
-					# sleep! otherwise, sometimes, rkward is left w/ an empty device window
-					Sys.sleep (.rk.renegade.devices.kill.time)
-					.rk.dev.off.default (x)
-				})
 		rk.record.plot$fixDeviceLists ()
 	}
-	return (.ret.value)
+
+	return (ret)
 }
 formals (dev.off) <- formals (grDevices::dev.off)
 .rk.dev.off.default <- grDevices::dev.off

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2010-06-24 15:14:46 UTC (rev 2901)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2010-06-25 06:08:38 UTC (rev 2902)
@@ -20,6 +20,7 @@
 #ifndef DISABLE_RKWINDOWCATCHER
 
 #include <qlayout.h>
+#include <qapplication.h>
 
 #include <kmessagebox.h>
 #include <klocale.h>
@@ -78,6 +79,16 @@
 	}
 }
 
+void RKWindowCatcher::killDevice (int device_number) {
+	RK_TRACE (MISC);
+
+	RKCaughtX11Window* window = RKCaughtX11Window::getWindow (device_number);
+	if (window) {
+		window->close (true);
+		QApplication::syncX ();
+	}
+}
+
 ///////////////////////////////// END RKWindowCatcher //////////////////////////////////
 /**************************************************************************************/
 //////////////////////////////// BEGIN RKCaughtX11Window //////////////////////////////

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.h	2010-06-24 15:14:46 UTC (rev 2901)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.h	2010-06-25 06:08:38 UTC (rev 2902)
@@ -71,6 +71,9 @@
 /** called from the R backend when the device history needs to be updated
 @param params the serialized parameters as supplied from R */
 	void updateHistory (QStringList params);
+/** Kill an R device
+ at param device_number R device number of the device to kil */
+	void killDevice (int device_number);
 private:
 	int last_cur_device;
 };


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