Hi,
Prasenjit Kapat schrieb:
On Thu, Jun 24, 2010 at 2:18 AM, Prasenjit Kapat <kap...@gmail.com> wrote:
Doing debug (dev.off) shows: (A) the current device (2) is closed and
(B) two new devices (3,4) are opened when .Internal (dev.off
(.......)) gets called.
somehow that mail appears to be lost.
Anyway, I guess the content is that it just didn't work.
I see that you found a workaround, but of course it would be best, if we
can fix the problem at its root. I suspect it's due to the fact that the
RKWard GUI thread attempts to do something with the X window, when it is
already gone in R. Then, for some reason, R spawns two new devices in
reaction to that. I'm attaching a patch that removes your workaround,
and tries to add some better synchronization instead. Since I still
don't see the issue, could you please test, whether this fixes the
problem for you?
Regards
Thomas
Index: rkward/windows/rkwindowcatcher.cpp
===================================================================
--- rkward/windows/rkwindowcatcher.cpp (Revision 2901)
+++ rkward/windows/rkwindowcatcher.cpp (Arbeitskopie)
@@ -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
//////////////////////////////
Index: rkward/windows/rkwindowcatcher.h
===================================================================
--- rkward/windows/rkwindowcatcher.h (Revision 2901)
+++ rkward/windows/rkwindowcatcher.h (Arbeitskopie)
@@ -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
+...@param device_number R device number of the device to kil */
+ void killDevice (int device_number);
private:
int last_cur_device;
};
Index: rkward/rbackend/rpackages/rkward/R/internal_graphics.R
===================================================================
--- rkward/rbackend/rpackages/rkward/R/internal_graphics.R (Revision 2899)
+++ rkward/rbackend/rpackages/rkward/R/internal_graphics.R (Arbeitskopie)
@@ -77,11 +77,6 @@
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 ()
@@ -89,24 +84,16 @@
# Why use 'which'? There is a which ()!!
if (!(which %in% .rk.preview.devices))
rk.record.plot$onDelDevice (deviceId = which)
- ldevs.before <- dev.list ()
+ .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
Index: rkward/rbackend/rinterface.cpp
===================================================================
--- rkward/rbackend/rinterface.cpp (Revision 2899)
+++ rkward/rbackend/rinterface.cpp (Arbeitskopie)
@@ -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 ();
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
RKWard-devel mailing list
RKWard-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rkward-devel