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

tfry at users.sf.net tfry at users.sf.net
Fri Mar 22 10:16:11 UTC 2013


Revision: 4617
          http://sourceforge.net/p/rkward/code/4617
Author:   tfry
Date:     2013-03-22 10:16:10 +0000 (Fri, 22 Mar 2013)
Log Message:
-----------
Rather ugly hack to work around lock-ups when trying to close an interactive device.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/windows/rkwindowcatcher.cpp
    trunk/rkward/rkward/windows/rkwindowcatcher.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2013-03-21 19:34:53 UTC (rev 4616)
+++ trunk/rkward/ChangeLog	2013-03-22 10:16:10 UTC (rev 4617)
@@ -1,4 +1,5 @@
 --- Version 0.6.1 - Apr-02-2013
+- Add option to force-close a graphics window		TODO: test on windows
 - Add plugin for subsetting data.frames by rows or columns
 - On the Windows platform, add an new (experimental) binary startup wrapper (rkward.exe)
 - Revert to building R packages form source on Mac OS X by default (controllable via compile-time option)

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2013-03-21 19:34:53 UTC (rev 4616)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2013-03-22 10:16:10 UTC (rev 4617)
@@ -2,7 +2,7 @@
                           rwindowcatcher.cpp  -  description
                              -------------------
     begin                : Wed May 4 2005
-    copyright            : (C) 2005, 2006, 2007, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2005 - 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -244,6 +244,18 @@
 	delete status_popup;
 }
 
+void RKCaughtX11Window::forceClose () {
+	if (capture) {
+#ifdef Q_WS_X11
+		// HACK: Somehow (R 3.0.0alpha), the X11() window is surpisingly die-hard, if it is not close "the regular way".
+		// So we expurge it, and leave the rest to the user.
+		capture->discardClient ();
+		qApp->processEvents ();
+#endif
+	}
+	RKMDIWindow::close (true);
+}
+
 bool RKCaughtX11Window::close (bool also_delete) {
 	RK_TRACE (MISC);
 
@@ -251,8 +263,17 @@
 		return RKMDIWindow::close (also_delete);
 	}
 
-	RCommand* c = new RCommand ("dev.off (" + QString::number (device_number) + ')', RCommand::App, i18n ("Shutting down device number %1", device_number), error_dialog);
-	setStatusMessage (i18n ("Closing device (saving history)"), c);
+	RCommand* c = new RCommand ("dev.off (" + QString::number (device_number) + ')', RCommand::App, i18n ("Shutting down device number %1", device_number));
+	QString status = i18n ("Closing device (saving history)");
+	setStatusMessage (status, c);
+	RKProgressControl *pc = new RKProgressControl (this, i18n ("<p>The graphics device is being closed, saving the last plot to the plot history. This may take a while, if the R backend is still busy. To close the graphics device immediately, click 'Cancel'. However, the last plot may be missing from the plot history, if you do this.</p>")
+#ifdef Q_WS_X11
+	+ i18n ("<p>Note: On X11, the embedded window may be expurged, when you press 'Cancel' and you will have to close it manually in this case.</p>")
+#endif
+	, status, RKProgressControl::CancellableNoProgress);
+	pc->addRCommand (c);
+	connect (pc, SIGNAL (cancelled()), this, SLOT (forceClose()));
+	pc->doNonModal (true);
 	RKGlobals::rInterface ()->issueCommand (c);
 
 	return false;

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.h	2013-03-21 19:34:53 UTC (rev 4616)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.h	2013-03-22 10:16:10 UTC (rev 4617)
@@ -2,7 +2,7 @@
                           rwindowcatcher.h  -  description
                              -------------------
     begin                : Wed May 4 2005
-    copyright            : (C) 2005, 2006, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2005 - 2013 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -157,6 +157,7 @@
 	void setKilledInR () { killed_in_r = true; };
 private slots:
 	void doEmbed ();
+	void forceClose ();
 private:
 	void reEmbed ();
 	void rCommandDone (RCommand *command);





More information about the rkward-tracker mailing list