[education/rkward] rkward/rbackend: Try to get more reliable behavior, in case of problems while starting the backend.

Thomas Friedrichsmeier null at kde.org
Sun Mar 6 08:58:15 GMT 2022


Git commit d50cd2403b7720359f372ee1c2379a1e5e00564d by Thomas Friedrichsmeier.
Committed on 06/03/2022 at 08:57.
Pushed by tfry into branch 'master'.

Try to get more reliable behavior, in case of problems while starting the backend.

M  +13   -9    rkward/rbackend/rkfrontendtransmitter.cpp

https://invent.kde.org/education/rkward/commit/d50cd2403b7720359f372ee1c2379a1e5e00564d

diff --git a/rkward/rbackend/rkfrontendtransmitter.cpp b/rkward/rbackend/rkfrontendtransmitter.cpp
index eb14a90d..98d0b431 100644
--- a/rkward/rbackend/rkfrontendtransmitter.cpp
+++ b/rkward/rbackend/rkfrontendtransmitter.cpp
@@ -111,8 +111,12 @@ void RKFrontendTransmitter::run () {
 	if (backend_executable.isEmpty ()) backend_executable = findBackendAtPath (QCoreApplication::applicationDirPath () + "/../../../rbackend");
 	if (backend_executable.isEmpty ()) backend_executable = findBackendAtPath (QCoreApplication::applicationDirPath () + "/../Frameworks/libexec");  // For running from .dmg created by craft --package rkward
 #endif
-	if (backend_executable.isEmpty ()) backend_executable = findBackendAtPath (RKWARD_BACKEND_PATH);
-	if (backend_executable.isEmpty ()) handleTransmissionError (i18n ("The backend executable could not be found. This is likely to be a problem with your installation."));
+	if (backend_executable.isEmpty()) backend_executable = findBackendAtPath(RKWARD_BACKEND_PATH);
+	if (backend_executable.isEmpty()) {
+		handleTransmissionError(i18n("The backend executable could not be found. This is likely to be a problem with your installation."));
+		exec();   // To actually show the transmission error
+		return;
+	}
 	QString debugger = RKGlobals::startup_options["backend-debugger"].toString ();
 	args.prepend (RKCommonFunctions::windowsShellScriptSafeCommand (backend_executable));
 	if (!debugger.isEmpty ()) {
@@ -135,15 +139,15 @@ void RKFrontendTransmitter::run () {
 	}
 	backend->start (qgetenv ("R_BINARY"), args, QIODevice::ReadOnly);
 
-	if (!backend->waitForStarted ()) {
-		handleTransmissionError (i18n ("The backend executable could not be started. Error message was: %1", backend->errorString ()));
+	if (!backend->waitForStarted()) {
+		handleTransmissionError(i18n("The backend executable could not be started. Error message was: %1", backend->errorString()));
+	} else {
+		waitForCanReadLine(backend, 3000);
+		token = QString::fromLocal8Bit(backend->readLine()).trimmed();
+		backend->closeReadChannel(QProcess::StandardError);
+		backend->closeReadChannel(QProcess::StandardOutput);
 	}
 
-	waitForCanReadLine (backend, 3000);
-	token = QString::fromLocal8Bit (backend->readLine ()).trimmed ();
-	backend->closeReadChannel (QProcess::StandardError);
-	backend->closeReadChannel (QProcess::StandardOutput);
-
 	exec ();
 
 	// It's ok to only give backend a short time to finish. We only get here, after QuitCommand has been handled by the backend


More information about the rkward-tracker mailing list