Commit 4fbc020d authored by Christian Stenger's avatar Christian Stenger
Browse files

Ensure we do not interfere with ourselves while parsing



Change-Id: I4e22e91273737321e7dbfa10e50b4ae1f4ee63f9
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
parent 8b4bdb6a
......@@ -59,6 +59,7 @@ TestCodeParser::TestCodeParser(TestTreeModel *parent)
m_fullUpdatePostponed(false),
m_partialUpdatePostponed(false),
m_dirty(true),
m_waitForParseTaskFinish(false),
m_parserState(Disabled)
{
// connect to ProgressManager to postpone test parsing when CppModelManager is parsing
......@@ -78,9 +79,11 @@ TestCodeParser::~TestCodeParser()
void TestCodeParser::setState(State state)
{
// avoid triggering parse before code model parsing has finished
if (m_codeModelParsing)
// avoid triggering parse before code model parsing has finished, but mark as dirty
if (m_codeModelParsing) {
m_dirty = true;
return;
}
if ((state == Disabled || state == Idle)
&& (m_parserState == PartialParse || m_parserState == FullParse))
......@@ -90,9 +93,13 @@ void TestCodeParser::setState(State state)
if (m_parserState == Disabled) {
m_fullUpdatePostponed = m_partialUpdatePostponed = false;
m_postponedFiles.clear();
} else if (m_parserState == Idle && m_dirty
&& ProjectExplorer::SessionManager::startupProject()) {
scanForTests(m_postponedFiles.toList());
} else if (m_parserState == Idle && ProjectExplorer::SessionManager::startupProject()) {
if (m_fullUpdatePostponed || m_dirty) {
emitUpdateTestTree();
} else if (m_partialUpdatePostponed) {
m_partialUpdatePostponed = false;
scanForTests(m_postponedFiles.toList());
}
}
}
......@@ -535,6 +542,17 @@ void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
}
}
void TestCodeParser::onStartupProjectChanged(ProjectExplorer::Project *)
{
if (m_parserState == FullParse || m_parserState == PartialParse) {
m_waitForParseTaskFinish = true;
Core::ProgressManager::instance()->cancelTasks(Constants::TASK_PARSE);
} else {
clearCache();
emitUpdateTestTree();
}
}
void TestCodeParser::onProjectPartsUpdated(ProjectExplorer::Project *project)
{
if (project != ProjectExplorer::SessionManager::startupProject())
......@@ -713,6 +731,8 @@ void TestCodeParser::onTaskStarted(Core::Id type)
{
if (type == CppTools::Constants::TASK_INDEX)
m_codeModelParsing = true;
else if (type == Constants::TASK_PARSE)
m_waitForParseTaskFinish = true;
}
void TestCodeParser::onAllTasksFinished(Core::Id type)
......@@ -721,19 +741,16 @@ void TestCodeParser::onAllTasksFinished(Core::Id type)
if (type != CppTools::Constants::TASK_INDEX)
return;
m_codeModelParsing = false;
// avoid illegal parser state if respective widgets became hidden while parsing
setState(Idle);
if (m_fullUpdatePostponed)
updateTestTree();
else if (m_partialUpdatePostponed) {
m_partialUpdatePostponed = false;
QStringList tmp;
foreach (const QString &file, m_postponedFiles)
tmp << file;
m_postponedFiles.clear();
scanForTests(tmp);
if (m_waitForParseTaskFinish && type == Constants::TASK_PARSE) {
m_waitForParseTaskFinish = false;
clearCache();
emitUpdateTestTree();
return;
}
// avoid illegal parser state if respective widgets became hidden while parsing
setState(Idle);
}
void TestCodeParser::onFinished()
......
......@@ -84,6 +84,7 @@ public slots:
void onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document);
void onQmlDocumentUpdated(const QmlJS::Document::Ptr &document);
void onStartupProjectChanged(ProjectExplorer::Project *);
void onProjectPartsUpdated(ProjectExplorer::Project *project);
void removeFiles(const QStringList &files);
void onProFileEvaluated();
......@@ -115,6 +116,7 @@ private:
bool m_fullUpdatePostponed;
bool m_partialUpdatePostponed;
bool m_dirty;
bool m_waitForParseTaskFinish;
QSet<QString> m_postponedFiles;
State m_parserState;
};
......
......@@ -102,7 +102,7 @@ void TestTreeModel::enableParsing()
ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
connect(sm, &ProjectExplorer::SessionManager::startupProjectChanged,
m_parser, &TestCodeParser::emitUpdateTestTree);
m_parser, &TestCodeParser::onStartupProjectChanged);
CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
connect(cppMM, &CppTools::CppModelManager::documentUpdated,
......
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