[rkward/work/faster_watch] rkward/rbackend/rpackages/rkward/R: Better handling of corner case

Thomas Friedrichsmeier null at kde.org
Mon Apr 9 09:41:16 UTC 2018


Git commit a92d6a2f34d29bd9d0ccd958a1043c4d3cf42d75 by Thomas Friedrichsmeier.
Committed on 09/04/2018 at 09:41.
Pushed by tfry into branch 'work/faster_watch'.

Better handling of corner case

M  +9    -5    rkward/rbackend/rpackages/rkward/R/internal.R

https://commits.kde.org/rkward/a92d6a2f34d29bd9d0ccd958a1043c4d3cf42d75

diff --git a/rkward/rbackend/rpackages/rkward/R/internal.R b/rkward/rbackend/rpackages/rkward/R/internal.R
index 76071519..256ebc88 100644
--- a/rkward/rbackend/rpackages/rkward/R/internal.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal.R
@@ -248,11 +248,15 @@
 
 #' @export
 ".rk.watch.symbol" <- function (k) {
-	f <- .rk.make.watch.f (k)
-	.Call ("rk.copy.no.eval", k, globalenv(), "x", environment (f), PACKAGE="(embedding)");
-	rm (list=k, envir=globalenv ())
-
-	.rk.makeActiveBinding.default (k, f, globalenv ())
+	if (bindingIsActive(k, globalenv())) {
+		# If the symbol already is an active binding, give up for now, as there is not currently a user-accessible way to copy an active binding (not just its value)
+		message("Note: RKWard cannot watch active binding ", k, " for changes.")
+	} else {
+		f <- .rk.make.watch.f (k)
+		.Call ("rk.copy.no.eval", k, globalenv(), "x", environment (f), PACKAGE="(embedding)");
+		rm (list=k, envir=globalenv ())
+		.rk.makeActiveBinding.default (k, f, globalenv ())
+	}
 	.rk.watched.symbols[[k]] <- TRUE
 
 	invisible (TRUE)



More information about the rkward-tracker mailing list