summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/codemodelbackendipc/connectionclient.cpp12
-rw-r--r--src/libs/codemodelbackendipc/connectionclient.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/src/libs/codemodelbackendipc/connectionclient.cpp b/src/libs/codemodelbackendipc/connectionclient.cpp
index 2bac59585a..61c12e4629 100644
--- a/src/libs/codemodelbackendipc/connectionclient.cpp
+++ b/src/libs/codemodelbackendipc/connectionclient.cpp
@@ -92,10 +92,22 @@ bool ConnectionClient::isConnected() const
return localSocket.state() == QLocalSocket::ConnectedState;
}
+void ConnectionClient::waitUntilSocketIsFlushed() const
+{
+ // Avoid to call QAbstractSocket::waitForBytesWritten(), which is known to
+ // be unreliable on Windows. Instead, call processEvents() to actually send
+ // the data.
+ while (localSocket.bytesToWrite() > 0) {
+ QCoreApplication::processEvents();
+ QThread::msleep(20);
+ }
+}
+
void ConnectionClient::sendEndCommand()
{
serverProxy_.end();
localSocket.flush();
+ waitUntilSocketIsFlushed();
}
void ConnectionClient::resetProcessAliveTimer()
diff --git a/src/libs/codemodelbackendipc/connectionclient.h b/src/libs/codemodelbackendipc/connectionclient.h
index e118db7116..2e2cb2ef15 100644
--- a/src/libs/codemodelbackendipc/connectionclient.h
+++ b/src/libs/codemodelbackendipc/connectionclient.h
@@ -96,6 +96,8 @@ private:
void disconnectProcessFinished() const;
void connectStandardOutputAndError() const;
+ void waitUntilSocketIsFlushed() const;
+
private:
mutable std::unique_ptr<QProcess> process_;
QLocalSocket localSocket;