[rkward/frameworks] rkward/rbackend: Give backend thread a chance to shutdown properly.

Thomas Friedrichsmeier null at kde.org
Sat May 20 08:00:02 UTC 2017


Git commit e8df47d8d09e87670072c33b9ce1e05fd7ac6ac1 by Thomas Friedrichsmeier.
Committed on 20/05/2017 at 07:57.
Pushed by tfry into branch 'frameworks'.

Give backend thread a chance to shutdown properly.

Should fix the "QProcess: Destroyed while process still running" warning.

M  +6    -4    rkward/rbackend/rkfrontendtransmitter.cpp
M  +3    -2    rkward/rbackend/rkrbackendprotocol_frontend.cpp

https://commits.kde.org/rkward/e8df47d8d09e87670072c33b9ce1e05fd7ac6ac1

diff --git a/rkward/rbackend/rkfrontendtransmitter.cpp b/rkward/rbackend/rkfrontendtransmitter.cpp
index c3c92801..1f735a9f 100644
--- a/rkward/rbackend/rkfrontendtransmitter.cpp
+++ b/rkward/rbackend/rkfrontendtransmitter.cpp
@@ -118,10 +118,10 @@ void RKFrontendTransmitter::run () {
 	if (!debugger.isEmpty ()) {
 		args = debugger.split (' ') + args;
 	}
-for (int i = 0; i < args.size (); ++i) {
-qDebug ("%s", qPrintable (args[i]));
-}
-qDebug ("%s", qPrintable (qgetenv ("R_BINARY")));
+	if (DL_DEBUG >= RK_Debug_Level) {
+		qDebug ("%s", qPrintable (args.join ("\n")));
+		qDebug ("%s", qPrintable (qgetenv ("R_BINARY")));
+	}
 	backend->start (qgetenv ("R_BINARY"), args, QIODevice::ReadOnly);
 
 	if (!backend->waitForStarted ()) {
@@ -142,6 +142,8 @@ qDebug ("%s", qPrintable (qgetenv ("R_BINARY")));
 
 	exec ();
 
+	backend->waitForFinished ();
+
 	if (!connection) {
 		RK_ASSERT (false);
 		return;
diff --git a/rkward/rbackend/rkrbackendprotocol_frontend.cpp b/rkward/rbackend/rkrbackendprotocol_frontend.cpp
index 9d03e3eb..8bd2d8c8 100644
--- a/rkward/rbackend/rkrbackendprotocol_frontend.cpp
+++ b/rkward/rbackend/rkrbackendprotocol_frontend.cpp
@@ -39,8 +39,9 @@ RKRBackendProtocolFrontend::~RKRBackendProtocolFrontend () {
 	RK_TRACE (RBACKEND);
 
 	terminateBackend ();
-	RKFrontendTransmitter::instance ()->quit ();
-	RKFrontendTransmitter::instance ()->wait (1000);
+	RKFrontendTransmitter::instance ()->wait (1000);  // Wait for thread to catch the backend's exit request, and exit()
+	RKFrontendTransmitter::instance ()->quit ();      // Tell it to quit, otherwise
+	RKFrontendTransmitter::instance ()->wait (1000);  // Wait for thread to quit and clean up.
 	delete RKFrontendTransmitter::instance ();
 }
 



More information about the rkward-tracker mailing list