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

tfry at users.sf.net tfry at users.sf.net
Wed Apr 24 17:48:40 UTC 2013


Revision: 4716
          http://sourceforge.net/p/rkward/code/4716
Author:   tfry
Date:     2013-04-24 17:48:37 +0000 (Wed, 24 Apr 2013)
Log Message:
-----------
More Windows compilations fixes. Turns out, R_PolledEvents is not available on Windows, either...

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rkrbackend.cpp
    trunk/rkward/rkward/rbackend/rkreventloop.cpp
    trunk/rkward/rkward/rbackend/rkreventloop.h

Modified: trunk/rkward/rkward/rbackend/rkrbackend.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkrbackend.cpp	2013-04-24 16:18:57 UTC (rev 4715)
+++ trunk/rkward/rkward/rbackend/rkrbackend.cpp	2013-04-24 17:48:37 UTC (rev 4716)
@@ -774,7 +774,7 @@
 	RK_R_Params.ReadConsole = RReadConsoleWin;
 	RK_R_Params.WriteConsoleEx = RWriteConsoleEx;
 	RK_R_Params.WriteConsole = 0;
-	RK_R_Params.CallBack = RDoNothing;
+	RK_R_Params.CallBack = RKREventLoop::winRKEventHandlerWrapper;
 	RK_R_Params.YesNoCancel = RAskYesNoCancel;
 	RK_R_Params.Busy = RBusy;
 

Modified: trunk/rkward/rkward/rbackend/rkreventloop.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkreventloop.cpp	2013-04-24 16:18:57 UTC (rev 4715)
+++ trunk/rkward/rkward/rbackend/rkreventloop.cpp	2013-04-24 17:48:37 UTC (rev 4716)
@@ -16,16 +16,16 @@
  ***************************************************************************/
 
 #include "rkreventloop.h"
+#include "rkrbackend.h"
 
-#ifdef Q_OS_WIN
+#ifdef Q_WS_WIN
+#	define Win32
 #	include <R.h>
 #else
 #	include <R_ext/eventloop.h>
 #endif
 #include <Rinternals.h>
 
-#include "rkrbackend.h"
-
 #include "../debug.h"
 
 extern "C" void RK_doIntr ();
@@ -72,10 +72,10 @@
 	RKRBackend::RKRBackend::repl_status.eval_depth--;
 }
 
-static void (* RK_old_R_PolledEvents)();
 static void (* RK_eventHandlerFunction)() = 0;
 
 #ifndef Q_OS_WIN
+static void (* RK_old_R_PolledEvents)();
 // NOTE: input-handler-based event loop mechanism is heavily inspired by (but not quite the same as in) package qtbase version 1.0.4 by Michael Lawrence, Deepayan Sarkar.
 // URL: http://qtinterfaces.r-forge.r-project.org
 static int ifd = 0;
@@ -91,20 +91,24 @@
 	RK_ASSERT (read_ok);
 	RK_eventHandlerFunction ();
 }
-#endif
 
 static void RK_eventHandlerChain () {
 	if (RK_eventHandlerFunction) RK_eventHandlerFunction ();
 	if (RK_old_R_PolledEvents) RK_old_R_PolledEvents ();
 }
+#else
+void RKREventLoop::winRKEventHandlerWrapper (void) {
+        if (RK_eventHandlerFunction) RK_eventHandlerFunction ();
+}
+#endif
 
 void RKREventLoop::setRKEventHandler (void (* handler) ()) {
 	RK_TRACE (RBACKEND);
 	RK_ASSERT (!RK_eventHandlerFunction);
 	RK_eventHandlerFunction = handler;
 
-	bool ok = false;
 #ifndef Q_OS_WIN
+        bool ok = false;
 	int fds[2];
 
 	if (!pipe (fds)) {
@@ -113,12 +117,12 @@
 		addInputHandler (R_InputHandlers, ifd, RK_eventHandlerWrapper, 32);
 		ok = true;
 	}
-#endif
 	if (ok) return;
 
 	// if pipe method did not work, fall back to R_PolledEvents
 	RK_old_R_PolledEvents = R_PolledEvents;
 	R_PolledEvents = RK_eventHandlerChain;
+#endif
 }
 
 void RKREventLoop::wakeRKEventHandler () {

Modified: trunk/rkward/rkward/rbackend/rkreventloop.h
===================================================================
--- trunk/rkward/rkward/rbackend/rkreventloop.h	2013-04-24 16:18:57 UTC (rev 4715)
+++ trunk/rkward/rkward/rbackend/rkreventloop.h	2013-04-24 17:48:37 UTC (rev 4716)
@@ -18,6 +18,8 @@
 #ifndef RKREVENTLOOP_H
 #define RKREVENTLOOP_H
 
+#include <qglobal.h>  // For Q_WS_WIN
+
 namespace RKREventLoop {
 /** This - somewhat misnamed - function takes care of processing R's events (not only X11).
  *  It is like R_ProcessEvents (except for the scary warning in the header file, that R_ProcessEvents does not work on Unix),
@@ -36,6 +38,9 @@
 /** Call this (potentially from a separate thread) to wake the handler set by setRKEventHandler() in the next iteration of 
  * R's event loop. */
 	void wakeRKEventHandler ();
+#ifdef Q_WS_WIN
+	void winRKEventHandlerWrapper (void);
+#endif
 };
 
 #endif





More information about the rkward-tracker mailing list