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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Sep 13 11:31:50 UTC 2010


Revision: 3027
          http://rkward.svn.sourceforge.net/rkward/?rev=3027&view=rev
Author:   tfry
Date:     2010-09-13 11:31:50 +0000 (Mon, 13 Sep 2010)

Log Message:
-----------
Throw in more synchronization, hoping to fix the "figure margins too large" error.

Modified Paths:
--------------
    trunk/rkward/rkward/windows/rkwindowcatcher.cpp
    trunk/rkward/tests/rkward_application_tests.R

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2010-09-13 08:04:13 UTC (rev 3026)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2010-09-13 11:31:50 UTC (rev 3027)
@@ -24,6 +24,7 @@
 
 #include <kmessagebox.h>
 #include <klocale.h>
+#include <kwindowsystem.h>
 
 #include "../rkwardapplication.h"
 #include "../settings/rksettingsmoduleoutput.h"
@@ -55,7 +56,14 @@
 	if (new_cur_device != last_cur_device) {
 		if (w) {
 			RKWorkplace::mainWorkplace ()->newX11Window (w, new_cur_device);
-			//new RKCaughtX11Window (w, new_cur_device);
+			// All this syncing looks like a bloody hack? Absolutely. It appears to work around the occasional error "figure margins too large" from R, though.
+			qApp->processEvents ();
+			qApp->syncX ();
+			qApp->processEvents ();
+#if defined Q_WS_X11
+			// this appears to have the side-effect of forcing the captured window to sync with X, which is exactly, what we're trying to achieve.
+			KWindowInfo wininfo = KWindowSystem::windowInfo (w, NET::WMName | NET::WMGeometry);
+#endif
 		} else {
 			KMessageBox::information (0, i18n ("You have created a new X11 device window in R. Usually, RKWard tries to detect such windows, to take control of them, and add a menu-bar to them. This time, however, RKWard failed to detect, which window was created, and so can not embed it.\nIf you created the window on a different screen or X11 display, that is to be expected. You might want to consider changing options(\"display\"), then.\nIf you can see the X11 window on the same screen as this message, then RKWard should do better. In this case, please contact us at rkward-devel at lists.sourceforge.net with details on your setup, so we can try to fix this in future versions of RKWard."), i18n ("Could not embed R X11 window"), "failure_to_detect_x11_device");
 		}
@@ -113,7 +121,6 @@
 #include <kdialog.h>
 #include <knuminput.h>
 #include <kvbox.h>
-#include <kwindowsystem.h>
 #include <kactioncollection.h>
 #include <kpassivepopup.h>
 

Modified: trunk/rkward/tests/rkward_application_tests.R
===================================================================
--- trunk/rkward/tests/rkward_application_tests.R	2010-09-13 08:04:13 UTC (rev 3026)
+++ trunk/rkward/tests/rkward_application_tests.R	2010-09-13 11:31:50 UTC (rev 3027)
@@ -70,10 +70,8 @@
 
 			plot (1, 1); x11(); plot (2, 2)
 
-			Sys.sleep (2)	# wait for everything to settle
 			stopifnot (all.equal (as.numeric (dev.list ()), c (2, 3)))
 			dev.off (2)
-			Sys.sleep (2)
 			stopifnot (all.equal (as.numeric (dev.list ()), 3))
 			dev.off ()
 			stopifnot (is.null (dev.list ()))
@@ -92,7 +90,6 @@
 			}
 
 			graphics.off()
-			Sys.sleep (2)	# wait for everything to settle
 			rk.clear.plot.history()
 			options(rk.graphics.hist.max.plotsize=1000)
 			rk.toggle.plot.history(TRUE)
@@ -200,7 +197,6 @@
 			compareCurrentPlotWith (plots[[6]])
 
 			graphics.off ()
-			Sys.sleep (2)	# wait for everything to settle
 			rk.clear.plot.history()
 
 			## Manage only screen devices
@@ -214,7 +210,6 @@
 			plot (3,3)
 			stopifnot (identical (c(1,2,4), as.numeric (rk.record.plot$.hP.names)))
 			graphics.off ()
-			Sys.sleep (2)	# wait for everything to settle
 			rk.clear.plot.history()
 			file.remove (fname)
 
@@ -242,10 +237,19 @@
 			stopifnot (rk.record.plot$sP.length == 6)
 
 			graphics.off ()
-			Sys.sleep (2)	# wait for everything to settle
 			rk.clear.plot.history()
 			message ("mark 10")
-		}, libraries=c ("lattice"))
+		}, libraries=c ("lattice")),
+		new ("RKTest", id="device_capturing_stress_test", call=function () {
+			# This test checks for the "figure margins too large" error, that used to occur when plotting on a fresh device, sometimes.
+			# Since the error only appeared occasionally, we try 100 times to produce it. Unfortunately, that does make the test run annoyingly long...
+			graphics.off()
+			for (i in 1:100) {
+				rk.screen.device ()
+				plot (rnorm (100))
+				dev.off ()
+			}
+		})
 	# postCalls are run *after* all tests. Use this to clean up
 	), postCalls = list (
 		function () {


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