forked from qt-creator/qt-creator
CMake: Make server-mode handle server restarts
Make ServerModeReader::parse handle the forceCMakeRun flag gracefully. The problem there was two-fold: 1. The server would send a "isReadyNow" signal when its connection is estabilshed. This made the ServerModeReader trigger another parse run with the same parameters. That would in turn would force a new ServerMode process to be created. 2. The "configure" request that is sent races the new ServerMode process being connected. Solve both issues by connecting a slot to the server-mode's connected signal and have that do the right thing. Change-Id: I26f9ac00d6ad6397a1fd1fab78610951f535ab53 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -148,8 +148,12 @@ void ServerModeReader::parse(bool forceCMakeRun, bool forceConfiguration)
|
|||||||
|
|
||||||
QTC_ASSERT(m_cmakeServer, return);
|
QTC_ASSERT(m_cmakeServer, return);
|
||||||
QVariantMap extra;
|
QVariantMap extra;
|
||||||
if (forceCMakeRun)
|
|
||||||
|
bool delayConfigurationRun = false;
|
||||||
|
if (forceCMakeRun && m_cmakeServer->isConnected()) {
|
||||||
createNewServer();
|
createNewServer();
|
||||||
|
delayConfigurationRun = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (forceConfiguration) {
|
if (forceConfiguration) {
|
||||||
QStringList cacheArguments = transform(m_parameters.configuration,
|
QStringList cacheArguments = transform(m_parameters.configuration,
|
||||||
@@ -173,8 +177,11 @@ void ServerModeReader::parse(bool forceCMakeRun, bool forceConfiguration)
|
|||||||
tr("Configuring \"%1\"").arg(m_parameters.projectName),
|
tr("Configuring \"%1\"").arg(m_parameters.projectName),
|
||||||
"CMake.Configure");
|
"CMake.Configure");
|
||||||
|
|
||||||
m_delayedErrorMessage.clear();
|
if (!delayConfigurationRun) {
|
||||||
m_cmakeServer->sendRequest(CONFIGURE_TYPE, extra);
|
sendConfigureRequest(extra);
|
||||||
|
} else {
|
||||||
|
m_delayedConfigurationData = extra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerModeReader::stop()
|
void ServerModeReader::stop()
|
||||||
@@ -367,8 +374,11 @@ void ServerModeReader::createNewServer()
|
|||||||
});
|
});
|
||||||
connect(m_cmakeServer.get(), &ServerMode::message,
|
connect(m_cmakeServer.get(), &ServerMode::message,
|
||||||
this, [](const QString &m) { Core::MessageManager::write(m); });
|
this, [](const QString &m) { Core::MessageManager::write(m); });
|
||||||
connect(m_cmakeServer.get(), &ServerMode::connected,
|
connect(m_cmakeServer.get(),
|
||||||
this, &ServerModeReader::isReadyNow, Qt::QueuedConnection); // Delay
|
&ServerMode::connected,
|
||||||
|
this,
|
||||||
|
&ServerModeReader::handleServerConnected,
|
||||||
|
Qt::QueuedConnection); // Delay
|
||||||
connect(m_cmakeServer.get(), &ServerMode::disconnected,
|
connect(m_cmakeServer.get(), &ServerMode::disconnected,
|
||||||
this, [this]() {
|
this, [this]() {
|
||||||
stop();
|
stop();
|
||||||
@@ -461,6 +471,22 @@ void ServerModeReader::handleSignal(const QString &signal, const QVariantMap &da
|
|||||||
emit dirty();
|
emit dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerModeReader::handleServerConnected()
|
||||||
|
{
|
||||||
|
if (m_delayedConfigurationData) {
|
||||||
|
sendConfigureRequest(*m_delayedConfigurationData);
|
||||||
|
m_delayedConfigurationData.reset();
|
||||||
|
} else {
|
||||||
|
emit isReadyNow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerModeReader::sendConfigureRequest(const QVariantMap &extra)
|
||||||
|
{
|
||||||
|
m_delayedErrorMessage.clear();
|
||||||
|
m_cmakeServer->sendRequest(CONFIGURE_TYPE, extra);
|
||||||
|
}
|
||||||
|
|
||||||
void ServerModeReader::reportError()
|
void ServerModeReader::reportError()
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ private:
|
|||||||
void handleError(const QString &message);
|
void handleError(const QString &message);
|
||||||
void handleProgress(int min, int cur, int max, const QString &inReplyTo);
|
void handleProgress(int min, int cur, int max, const QString &inReplyTo);
|
||||||
void handleSignal(const QString &signal, const QVariantMap &data);
|
void handleSignal(const QString &signal, const QVariantMap &data);
|
||||||
|
void handleServerConnected();
|
||||||
|
|
||||||
|
void sendConfigureRequest(const QVariantMap &extra);
|
||||||
|
|
||||||
void reportError();
|
void reportError();
|
||||||
|
|
||||||
@@ -163,6 +166,8 @@ private:
|
|||||||
int m_progressStepMinimum = 0;
|
int m_progressStepMinimum = 0;
|
||||||
int m_progressStepMaximum = 1000;
|
int m_progressStepMaximum = 1000;
|
||||||
|
|
||||||
|
Utils::optional<QVariantMap> m_delayedConfigurationData;
|
||||||
|
|
||||||
QString m_delayedErrorMessage;
|
QString m_delayedErrorMessage;
|
||||||
|
|
||||||
CMakeConfig m_cmakeConfiguration;
|
CMakeConfig m_cmakeConfiguration;
|
||||||
|
|||||||
Reference in New Issue
Block a user