server-mode: Always try to read CMakeCache, even after error

Change-Id: Ib3d4fb5ac14340a7f706e4a1d8a0cbdc420d01d1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Tobias Hunger
2017-12-07 16:25:47 +01:00
parent dd9c7de89a
commit fdccc54275
4 changed files with 71 additions and 40 deletions

View File

@@ -356,8 +356,6 @@ QList<CMakeBuildTarget> BuildDirManager::takeBuildTargets() const
CMakeConfig BuildDirManager::takeCMakeConfiguration() const
{
QTC_ASSERT(!m_isHandlingError, return {});
if (!m_reader)
return CMakeConfig();

View File

@@ -106,6 +106,7 @@ CMakeProject::CMakeProject(const FileName &fileName) : Project(Constants::CMAKEM
CMakeBuildConfiguration *bc = activeBc(this);
if (bc && bc == m_buildDirManager.buildConfiguration()) {
bc->setError(msg);
bc->setConfigurationFromCMake(m_buildDirManager.takeCMakeConfiguration());
handleParsingError(bc);
}
});

View File

@@ -196,6 +196,7 @@ void ServerModeReader::parse(bool forceConfiguration)
tr("Configuring \"%1\"").arg(m_parameters.projectName),
"CMake.Configure");
m_delayedErrorMessage.clear();
m_cmakeServer->sendRequest(CONFIGURE_TYPE, extra);
}
@@ -386,7 +387,13 @@ void ServerModeReader::updateCodeModel(CppTools::RawProjectParts &rpps)
void ServerModeReader::handleReply(const QVariantMap &data, const QString &inReplyTo)
{
Q_UNUSED(data);
if (!m_delayedErrorMessage.isEmpty()) {
// Handle reply to cache after error:
if (inReplyTo == CACHE_TYPE)
extractCacheData(data);
reportError();
} else {
// No error yet:
if (inReplyTo == CONFIGURE_TYPE) {
m_cmakeServer->sendRequest(COMPUTE_TYPE);
if (m_future)
@@ -423,15 +430,24 @@ void ServerModeReader::handleReply(const QVariantMap &data, const QString &inRep
Core::MessageManager::write(tr("CMake Project was parsed successfully."));
emit dataAvailable();
}
}
}
void ServerModeReader::handleError(const QString &message)
{
TaskHub::addTask(Task::Error, message, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM,
Utils::FileName(), -1);
stop();
Core::MessageManager::write(tr("CMake Project parsing failed."));
emit errorOccured(message);
if (!m_delayedErrorMessage.isEmpty()) {
reportError();
return;
}
m_delayedErrorMessage = message;
// Always try to read CMakeCache, even after an error!
m_cmakeServer->sendRequest(CACHE_TYPE);
if (m_future)
m_future->setProgressValue(1300);
}
void ServerModeReader::handleProgress(int min, int cur, int max, const QString &inReplyTo)
@@ -452,6 +468,18 @@ void ServerModeReader::handleSignal(const QString &signal, const QVariantMap &da
emit dirty();
}
void ServerModeReader::reportError()
{
stop();
Core::MessageManager::write(tr("CMake Project parsing failed."));
emit errorOccured(m_delayedErrorMessage);
if (m_future)
m_future->reportCanceled();
m_delayedErrorMessage.clear();
}
int ServerModeReader::calculateProgress(const int minRange, const int min, const int cur, const int max, const int maxRange)
{
if (minRange == maxRange || min == max)

View File

@@ -68,6 +68,8 @@ private:
void handleProgress(int min, int cur, int max, const QString &inReplyTo);
void handleSignal(const QString &signal, const QVariantMap &data);
void reportError();
int calculateProgress(const int minRange, const int min,
const int cur,
const int max, const int maxRange);
@@ -166,6 +168,8 @@ private:
int m_progressStepMinimum = 0;
int m_progressStepMaximum = 1000;
QString m_delayedErrorMessage;
CMakeConfig m_cmakeConfiguration;
QSet<Utils::FileName> m_cmakeFiles;