[rkward/frameworks] /: Fix startup crash on Windows (well, one of the two startup crashes...)

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Feb 22 20:17:22 UTC 2016


Git commit 35205d2fc1dfd55655273669388dbe3cc4e9a13e by Thomas Friedrichsmeier.
Committed on 22/02/2016 at 20:16.
Pushed by tfry into branch 'frameworks'.

Fix startup crash on Windows (well, one of the two startup crashes...)
Silence cmake warnings.

M  +3    -0    CMakeLists.txt
M  +11   -1    rkward/rbackend/rkfrontendtransmitter.cpp
M  +1    -1    rkward/rkward_startup_wrapper.cpp

http://commits.kde.org/rkward/35205d2fc1dfd55655273669388dbe3cc4e9a13e

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0bb2489..68b29bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,9 @@
 PROJECT(rkward)
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)	# As required by KF5
+IF(NOT "${CMAKE_VERSION}" VERSION_LESS 3.3.0)
+	CMAKE_POLICY(SET CMP0063 OLD)  # No symbol visibility in any of our static libraries needed
+ENDIF()
 
 IF(NOT CMAKE_VERBOSE_MAKEFILE)
 	SET (FORCE_PRETTY_MAKEFILE ON)
diff --git a/rkward/rbackend/rkfrontendtransmitter.cpp b/rkward/rbackend/rkfrontendtransmitter.cpp
index 00393e6..6e9eb94 100644
--- a/rkward/rbackend/rkfrontendtransmitter.cpp
+++ b/rkward/rbackend/rkfrontendtransmitter.cpp
@@ -32,6 +32,7 @@
 #include <QLocalSocket>
 #include <QDir>
 #include <QStandardPaths>
+#include <QTime>
 
 #include "../version.h"
 #include "../debug.h"
@@ -120,7 +121,13 @@ void RKFrontendTransmitter::run () {
 	}
 
 	// fetch security token
-	if (!backend->canReadLine ()) backend->waitForReadyRead ();
+	{
+		// NOTE: On Qt5+Windows, readyReady may actually come in char by char, so calling waitForReadyRead() does not guaranteed we will
+		//       see the full line, at all. But also, of course, we want to put some cap on trying. Using a time threshold for this.
+		QTime time;
+		time.start ();
+		while ((!backend->canReadLine ()) && (time.elapsed () < 3000)) backend->waitForReadyRead ();
+	}
 	token = QString::fromLocal8Bit (backend->readLine ()).trimmed ();
 	backend->closeReadChannel (QProcess::StandardError);
 	backend->closeReadChannel (QProcess::StandardOutput);
@@ -140,6 +147,9 @@ void RKFrontendTransmitter::connectAndEnterLoop () {
 	QLocalSocket *con = server->nextPendingConnection ();
 	server->close ();
 
+	// NOTE: Not the same as setConnection(), below, but needed in case of transmission errors.
+	connection = con;
+
 	// handshake
 	if (!con->canReadLine ()) con->waitForReadyRead (1000);
 	QString token_c = QString::fromLocal8Bit (con->readLine ());
diff --git a/rkward/rkward_startup_wrapper.cpp b/rkward/rkward_startup_wrapper.cpp
index 09d6492..f3c5071 100644
--- a/rkward/rkward_startup_wrapper.cpp
+++ b/rkward/rkward_startup_wrapper.cpp
@@ -308,7 +308,7 @@ int main (int argc, char *argv[]) {
 			for (int i = 0;  i < call_args.length (); ++i) {
 				vbs << " " << call_args[i];
 			}
-			vbs << "\", 0\r\nSet WomScriptHost = Nothing\r\n";
+			vbs << "\", 0\r\nSet WinScriptHost = Nothing\r\n";
 			vbsf->close ();
 			QString filename = vbsf->fileName ();
 			delete (vbsf);  // somehow, if creating vbsf on the stack, we cannot launch it, because "file is in use by another process", despite we have closed it.



More information about the rkward-tracker mailing list