[rkward-cvs] SF.net SVN: rkward:[2897] trunk/rkward/rkward/rbackend/rpackages/rkward/R

kapatp at users.sourceforge.net kapatp at users.sourceforge.net
Thu Jun 24 09:04:24 UTC 2010


Revision: 2897
          http://rkward.svn.sourceforge.net/rkward/?rev=2897&view=rev
Author:   kapatp
Date:     2010-06-24 09:04:24 +0000 (Thu, 24 Jun 2010)

Log Message:
-----------
A stop-gap solution for the dev.off () problem; see here: http://thread.gmane.org/gmane.comp.statistics.rkward.devel/802. This so-called fix should not affect those who are not affected by the bug.

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R	2010-06-24 08:41:31 UTC (rev 2896)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R	2010-06-24 09:04:24 UTC (rev 2897)
@@ -82,16 +82,35 @@
 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 ()
 	}
 	
 	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)
 }
 formals (dev.off) <- formals (grDevices::dev.off)

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R	2010-06-24 08:41:31 UTC (rev 2896)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R	2010-06-24 09:04:24 UTC (rev 2897)
@@ -143,6 +143,15 @@
 		message ('Current devices: ', paste (unlist (current), collapse = ', ')) 
 		message ('New plot exists? ', paste (unlist (newPlotExists), collapse = ', ')) 
 	}
+	fixDeviceLists <- function ()
+	{
+		maxdeviceId <- ifelse (is.null (dev.list()), 1, max (dev.list()))
+		if (maxdeviceId < length (current)) {
+			current <<- current [1:maxdeviceId]
+			newPlotExists <<- newPlotExists [1:maxdeviceId]
+		}
+		invisible ()
+	}
 	env
 }
 rk.record.plot <- rk.record.plot ()


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