Commit a3a7e708 authored by Daniel Teske's avatar Daniel Teske
Browse files

Qt4Nodes: Fix wrong "Parsing in progress" warning for some cases



Removing a subproject and changing the project type of a parent project
didn't set always the valid parse state nor emitted the parsing finished
signal. Also ensure that removing and then readding a node does update
the runconfiguration for that node.

Note: The error message is now: "The .pro file %1 could not be parsed",
which is better, but can be improved, improving that is QTCREATORBUG-7377

Task-number: QTCREATORBUG-7394

Change-Id: Ie0d9a430ee902bd194179b0512ac8295bc519f2a
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent e664a536
...@@ -1234,17 +1234,6 @@ void Qt4PriFileNode::save(const QStringList &lines) ...@@ -1234,17 +1234,6 @@ void Qt4PriFileNode::save(const QStringList &lines)
m_project->qt4ProjectManager()->notifyChanged(m_projectFilePath); m_project->qt4ProjectManager()->notifyChanged(m_projectFilePath);
} }
/*
Deletes all subprojects/files/virtual folders
*/
void Qt4PriFileNode::clear()
{
// delete files && folders && projects
removeFileNodes(fileNodes(), this);
removeProjectNodes(subProjectNodes());
removeFolderNodes(subFolderNodes(), this);
}
QStringList Qt4PriFileNode::varNames(ProjectExplorer::FileType type) QStringList Qt4PriFileNode::varNames(ProjectExplorer::FileType type)
{ {
QStringList vars; QStringList vars;
...@@ -1520,7 +1509,7 @@ Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project, ...@@ -1520,7 +1509,7 @@ Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project,
: Qt4PriFileNode(project, this, filePath), : Qt4PriFileNode(project, this, filePath),
m_projectType(InvalidProject), m_projectType(InvalidProject),
m_validParse(false), m_validParse(false),
m_parseInProgress(false), m_parseInProgress(true),
m_readerExact(0), m_readerExact(0),
m_readerCumulative(0) m_readerCumulative(0)
{ {
...@@ -1629,6 +1618,25 @@ void Qt4ProFileNode::setParseInProgress(bool b) ...@@ -1629,6 +1618,25 @@ void Qt4ProFileNode::setParseInProgress(bool b)
emit qt4Watcher->proFileUpdated(this, m_validParse, m_parseInProgress); emit qt4Watcher->proFileUpdated(this, m_validParse, m_parseInProgress);
} }
void Qt4ProFileNode::setValidParseRecursive(bool b)
{
setValidParse(b);
foreach (ProjectNode *subNode, subProjectNodes()) {
if (Qt4ProFileNode *node = qobject_cast<Qt4ProFileNode *>(subNode)) {
node->setValidParseRecursive(b);
}
}
}
// Do note the absence of signal emission, always set validParse
// before setParseInProgress, as that will emit the signals
void Qt4ProFileNode::setValidParse(bool b)
{
if (m_validParse == b)
return;
m_validParse = b;
}
bool Qt4ProFileNode::validParse() const bool Qt4ProFileNode::validParse() const
{ {
return m_validParse; return m_validParse;
...@@ -1714,11 +1722,27 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async) ...@@ -1714,11 +1722,27 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async)
m_project->destroyProFileReader(m_readerExact); m_project->destroyProFileReader(m_readerExact);
m_project->destroyProFileReader(m_readerCumulative); m_project->destroyProFileReader(m_readerCumulative);
m_readerExact = m_readerCumulative = 0; m_readerExact = m_readerCumulative = 0;
setValidParseRecursive(false);
setParseInProgressRecursive(false);
if (evalResult == EvalFail) { if (evalResult == EvalFail) {
m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath)); m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
invalidate(); if (m_projectType == InvalidProject)
return;
// delete files && folders && projects
removeFileNodes(fileNodes(), this);
removeProjectNodes(subProjectNodes());
removeFolderNodes(subFolderNodes(), this);
// change project type
Qt4ProjectType oldType = m_projectType;
m_projectType = InvalidProject;
foreach (ProjectExplorer::NodesWatcher *watcher, watchers())
if (Internal::Qt4NodesWatcher *qt4Watcher = qobject_cast<Internal::Qt4NodesWatcher*>(watcher))
emit qt4Watcher->projectTypeChanged(this, oldType, InvalidProject);
} }
setParseInProgressRecursive(false);
return; return;
} }
...@@ -1729,8 +1753,19 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async) ...@@ -1729,8 +1753,19 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async)
(evalResult == EvalOk ? m_readerExact : m_readerCumulative)->templateType()); (evalResult == EvalOk ? m_readerExact : m_readerCumulative)->templateType());
if (projectType != m_projectType) { if (projectType != m_projectType) {
Qt4ProjectType oldType = m_projectType; Qt4ProjectType oldType = m_projectType;
// probably all subfiles/projects have changed anyway ... // probably all subfiles/projects have changed anyway
clear(); // delete files && folders && projects
foreach (ProjectNode *projectNode, subProjectNodes()) {
if (Qt4ProFileNode *qt4ProFileNode = qobject_cast<Qt4ProFileNode *>(projectNode)) {
qt4ProFileNode->setValidParseRecursive(false);
qt4ProFileNode->setParseInProgressRecursive(false);
}
}
removeFileNodes(fileNodes(), this);
removeProjectNodes(subProjectNodes());
removeFolderNodes(subFolderNodes(), this);
bool changesHasBuildTargets = hasBuildTargets() ^ hasBuildTargets(projectType); bool changesHasBuildTargets = hasBuildTargets() ^ hasBuildTargets(projectType);
if (changesHasBuildTargets) if (changesHasBuildTargets)
...@@ -1913,6 +1948,13 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async) ...@@ -1913,6 +1948,13 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async)
} }
} // for } // for
foreach (ProjectNode *node, toRemove) {
if (Qt4ProFileNode *qt4ProFileNode = qobject_cast<Qt4ProFileNode *>(node)) {
qt4ProFileNode->setValidParseRecursive(false);
qt4ProFileNode->setParseInProgressRecursive(false);
}
}
if (!toRemove.isEmpty()) if (!toRemove.isEmpty())
removeProjectNodes(toRemove); removeProjectNodes(toRemove);
if (!toAdd.isEmpty()) if (!toAdd.isEmpty())
...@@ -2399,26 +2441,6 @@ QString Qt4ProFileNode::buildDir(Qt4BuildConfiguration *bc) const ...@@ -2399,26 +2441,6 @@ QString Qt4ProFileNode::buildDir(Qt4BuildConfiguration *bc) const
return QDir(bc->buildDirectory()).absoluteFilePath(relativeDir); return QDir(bc->buildDirectory()).absoluteFilePath(relativeDir);
} }
/*
Sets project type to InvalidProject & deletes all subprojects/files/virtual folders
*/
void Qt4ProFileNode::invalidate()
{
if (m_projectType == InvalidProject)
return;
clear();
// change project type
Qt4ProjectType oldType = m_projectType;
m_projectType = InvalidProject;
foreach (ProjectExplorer::NodesWatcher *watcher, watchers())
if (Internal::Qt4NodesWatcher *qt4Watcher = qobject_cast<Internal::Qt4NodesWatcher*>(watcher))
emit qt4Watcher->projectTypeChanged(this, oldType, InvalidProject);
}
void Qt4ProFileNode::updateCodeModelSupportFromBuild(const QStringList &files) void Qt4ProFileNode::updateCodeModelSupportFromBuild(const QStringList &files)
{ {
foreach (const QString &file, files) { foreach (const QString &file, files) {
......
...@@ -167,7 +167,6 @@ public: ...@@ -167,7 +167,6 @@ public:
protected: protected:
void setIncludedInExactParse(bool b); void setIncludedInExactParse(bool b);
void clear();
static QStringList varNames(FileType type); static QStringList varNames(FileType type);
static QStringList dynamicVarNames(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative); static QStringList dynamicVarNames(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative);
static QSet<Utils::FileName> filterFilesProVariables(ProjectExplorer::FileType fileType, const QSet<Utils::FileName> &files); static QSet<Utils::FileName> filterFilesProVariables(ProjectExplorer::FileType fileType, const QSet<Utils::FileName> &files);
...@@ -395,6 +394,8 @@ public: ...@@ -395,6 +394,8 @@ public:
void setParseInProgress(bool b); void setParseInProgress(bool b);
void setParseInProgressRecursive(bool b); void setParseInProgressRecursive(bool b);
void setValidParse(bool b);
void setValidParseRecursive(bool b);
void emitProFileUpdatedRecursive(); void emitProFileUpdatedRecursive();
public slots: public slots:
void asyncUpdate(); void asyncUpdate();
...@@ -427,8 +428,6 @@ private: ...@@ -427,8 +428,6 @@ private:
void setupInstallsList(const QtSupport::ProFileReader *reader); void setupInstallsList(const QtSupport::ProFileReader *reader);
void setupProjectVersion(const QtSupport::ProFileReader *reader); void setupProjectVersion(const QtSupport::ProFileReader *reader);
void invalidate();
Qt4ProjectType m_projectType; Qt4ProjectType m_projectType;
Qt4VariablesHash m_varValues; Qt4VariablesHash m_varValues;
bool m_isDeployable; bool m_isDeployable;
......
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