diff options
Diffstat (limited to 'src/libs/codemodelbackendipc/connectionclient.cpp')
-rw-r--r-- | src/libs/codemodelbackendipc/connectionclient.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/libs/codemodelbackendipc/connectionclient.cpp b/src/libs/codemodelbackendipc/connectionclient.cpp index 61c12e4629..de3b9b7649 100644 --- a/src/libs/codemodelbackendipc/connectionclient.cpp +++ b/src/libs/codemodelbackendipc/connectionclient.cpp @@ -53,11 +53,14 @@ QString connectionName() } ConnectionClient::ConnectionClient(IpcClientInterface *client) - : serverProxy_(client, &localSocket) + : serverProxy_(client, &localSocket), + isAliveTimerResetted(false) { processAliveTimer.setInterval(10000); - connect(&processAliveTimer, &QTimer::timeout, this, &ConnectionClient::restartProcess); + connect(&processAliveTimer, &QTimer::timeout, + this, &ConnectionClient::restartProcessIfTimerIsNotResettedAndSocketIsEmpty); + connect(&localSocket, static_cast<void (QLocalSocket::*)(QLocalSocket::LocalSocketError)>(&QLocalSocket::error), this, @@ -112,6 +115,7 @@ void ConnectionClient::sendEndCommand() void ConnectionClient::resetProcessAliveTimer() { + isAliveTimerResetted = true; processAliveTimer.start(); } @@ -127,7 +131,7 @@ void ConnectionClient::startProcess() connectStandardOutputAndError(); process()->start(processPath(), {connectionName()}); process()->waitForStarted(); - processAliveTimer.start(); + resetProcessAliveTimer(); } } @@ -141,6 +145,19 @@ void ConnectionClient::restartProcess() emit processRestarted(); } +void ConnectionClient::restartProcessIfTimerIsNotResettedAndSocketIsEmpty() +{ + if (isAliveTimerResetted) { + isAliveTimerResetted = false; + return; // Already reset, but we were scheduled after. + } + + if (localSocket.bytesAvailable() > 0) + return; // We come first, the incoming data was not yet processed. + + restartProcess(); +} + bool ConnectionClient::connectToLocalSocket() { QThread::msleep(30); |