CMake: Return empty tree on errors in server-mode

This triggers the fallback mechanism which will make sure the CMakeLists.txt
file will be displayed.

This used to fail since one empty folder was left over in the project.

Task-number: QTCREATORBUG-17383
Change-Id: I867fd9039bc5df805ff5174ec49084bbcf688824
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2016-12-02 17:32:31 +01:00
parent 7e10f84c2e
commit 45ad669a88
4 changed files with 33 additions and 20 deletions

View File

@@ -142,19 +142,25 @@ void CMakeBuildConfiguration::ctor()
displayName(), BuildConfiguration::Unknown));
connect(m_buildDirManager.get(), &BuildDirManager::dataAvailable,
this, &CMakeBuildConfiguration::dataAvailable);
this, [this, project]() {
project->updateProjectData(this);
emit dataAvailable();
});
connect(m_buildDirManager.get(), &BuildDirManager::errorOccured,
this, &CMakeBuildConfiguration::setError);
this, [this, project](const QString &msg) {
project->updateProjectData(this);
setError(msg);
});
connect(m_buildDirManager.get(), &BuildDirManager::configurationStarted,
this, &CMakeBuildConfiguration::parsingStarted);
this, [this, project]() {
project->handleParsingStarted();
emit parsingStarted();
});
connect(this, &CMakeBuildConfiguration::environmentChanged,
m_buildDirManager.get(), &BuildDirManager::forceReparse);
connect(this, &CMakeBuildConfiguration::buildDirectoryChanged,
m_buildDirManager.get(), &BuildDirManager::forceReparse);
connect(this, &CMakeBuildConfiguration::parsingStarted, project, &CMakeProject::handleParsingStarted);
connect(this, &CMakeBuildConfiguration::dataAvailable, project, &CMakeProject::updateProjectData);
}
void CMakeBuildConfiguration::maybeForceReparse()
@@ -378,10 +384,10 @@ CMakeConfig CMakeBuildConfiguration::cmakeConfiguration() const
void CMakeBuildConfiguration::setError(const QString &message)
{
if (m_error == message)
return;
m_error = message;
if (m_error != message) {
emit enabledChanged();
m_error = message;
}
emit errorOccured(m_error);
}

View File

@@ -94,17 +94,16 @@ CMakeProject::~CMakeProject()
qDeleteAll(m_extraCompilers);
}
void CMakeProject::updateProjectData()
void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
{
auto cmakeBc = qobject_cast<CMakeBuildConfiguration *>(sender());
QTC_ASSERT(cmakeBc, return);
QTC_ASSERT(bc, return);
Target *t = activeTarget();
if (!t || t->activeBuildConfiguration() != cmakeBc)
if (!t || t->activeBuildConfiguration() != bc)
return;
Kit *k = t->kit();
cmakeBc->generateProjectTree(static_cast<CMakeListsNode *>(rootProjectNode()));
bc->generateProjectTree(static_cast<CMakeListsNode *>(rootProjectNode()));
updateApplicationAndDeploymentTargets();
updateTargetRunConfigurations(t);
@@ -131,7 +130,7 @@ void CMakeProject::updateProjectData()
ppBuilder.setQtVersion(activeQtVersion);
const QSet<Core::Id> languages = cmakeBc->updateCodeModel(ppBuilder);
const QSet<Core::Id> languages = bc->updateCodeModel(ppBuilder);
for (const auto &lid : languages)
setProjectLanguage(lid, true);
@@ -144,7 +143,7 @@ void CMakeProject::updateProjectData()
emit displayNameChanged();
emit fileListChanged();
emit cmakeBc->emitBuildTypeChanged();
emit bc->emitBuildTypeChanged();
emit parsingFinished();
}

View File

@@ -113,7 +113,7 @@ private:
void handleActiveTargetChanged();
void handleActiveBuildConfigurationChanged();
void handleParsingStarted();
void updateProjectData();
void updateProjectData(Internal::CMakeBuildConfiguration *cmakeBc);
void updateQmlJSCodeModel();
void createGeneratedCodeModelSupport();

View File

@@ -250,12 +250,20 @@ static ProjectNode *updateCMakeInputs(CMakeListsNode *root,
QList<FileNode *> &buildInputs,
QList<FileNode *> &rootInputs)
{
const bool hasInputs = !sourceInputs.isEmpty() || !buildInputs.isEmpty() || !rootInputs.isEmpty();
ProjectNode *cmakeVFolder
= root->projectNode(CMakeInputsNode::inputsPathFromCMakeListsPath(root->filePath()));
if (!cmakeVFolder) {
if (hasInputs) {
cmakeVFolder = new CMakeInputsNode(root->filePath());
root->addProjectNodes({ cmakeVFolder });
}
} else {
if (!hasInputs)
root->removeProjectNodes({ cmakeVFolder });
}
if (!hasInputs)
return nullptr;
QList<FolderNode *> foldersToDelete;
foldersToDelete.append(setupCMakeVFolder(cmakeVFolder, sourceDir, 1000,