Commit db6b6087 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Make connections in server-mode setup more robust

Change-Id: I1e66b4decd485edac9e3fb5508d5c0bb10d0554a
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent f0bf6211
......@@ -145,11 +145,6 @@ void BuildDirManager::maybeForceReparseOnceReaderReady()
const QByteArrayList criticalKeys
= QByteArrayList() << GENERATOR_KEY << CMAKE_COMMAND_KEY;
if (!m_reader->hasData()) {
forceReparse();
return;
}
const CMakeConfig currentConfig = parsedConfiguration();
Kit *k = m_buildConfiguration->target()->kit();
......@@ -371,6 +366,11 @@ void BuildDirManager::checkConfiguration()
void BuildDirManager::maybeForceReparse()
{
if (!m_reader || !m_reader->hasData()) {
forceReparse();
return;
}
updateReaderType([this]() { maybeForceReparseOnceReaderReady(); });
}
......
......@@ -128,7 +128,7 @@ ServerMode::~ServerMode()
m_cmakeProcess->disconnect();
if (m_cmakeSocket) {
m_cmakeSocket->disconnect();
m_cmakeSocket->disconnectFromServer();
m_cmakeSocket->abort();
delete(m_cmakeSocket);
}
m_cmakeSocket = nullptr;
......@@ -184,16 +184,18 @@ void ServerMode::connectToServer()
QTC_ASSERT(!m_cmakeSocket, return);
auto socket = new QLocalSocket(m_cmakeProcess.get());
connect(socket, &QLocalSocket::readyRead,
this, &ServerMode::handleRawCMakeServerData);
connect(socket, &QLocalSocket::readyRead, this, &ServerMode::handleRawCMakeServerData);
connect(socket, static_cast<void(QLocalSocket::*)(QLocalSocket::LocalSocketError)>(&QLocalSocket::error),
[this, socket]() {
this, [this, socket]() {
reportError(socket->errorString());
m_cmakeSocket = nullptr;
socket->disconnect();
socket->deleteLater();
});
connect(socket, &QLocalSocket::connected, [this, socket]() { m_cmakeSocket = socket; });
connect(socket, &QLocalSocket::disconnected, [this, socket]() {
connect(socket, &QLocalSocket::connected, this, [this, socket]() { m_cmakeSocket = socket; });
connect(socket, &QLocalSocket::disconnected, this, [this, socket]() {
if (m_cmakeSocket)
emit disconnected();
m_cmakeSocket = nullptr;
socket->disconnect();
socket->deleteLater();
......@@ -352,6 +354,7 @@ void ServerMode::parseJson(const QVariantMap &data)
emit cmakeError(data.value("errorMessage").toString(), replyTo, cookie);
if (replyTo == HANDSHAKE_TYPE) {
Core::Reaper::reap(m_cmakeProcess.release());
m_cmakeSocket->disconnect();
m_cmakeSocket->disconnectFromServer();
m_cmakeSocket = nullptr;
emit disconnected();
......
......@@ -110,9 +110,9 @@ void ServerModeReader::setParameters(const BuildDirReader::Parameters &p)
connect(m_cmakeServer.get(), &ServerMode::message,
this, [](const QString &m) { Core::MessageManager::write(m); });
connect(m_cmakeServer.get(), &ServerMode::connected,
this, &ServerModeReader::isReadyNow);
this, &ServerModeReader::isReadyNow, Qt::QueuedConnection); // Delay
connect(m_cmakeServer.get(), &ServerMode::disconnected,
this, [this]() { m_cmakeServer.reset(); });
this, [this]() { m_cmakeServer.reset(); }, Qt::QueuedConnection); // Delay
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment