summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-07-27 10:44:14 +0200
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-08-06 14:53:37 +0300
commit4fbc020ddc8d353aba8c2c3c79223eaf09be573e (patch)
treec7fd1b9962cc457f9a2ba1d0161a83b707865433
parent8b4bdb6a0023806cf869ec344d75854cd7a848ce (diff)
downloadqt-creator-4fbc020ddc8d353aba8c2c3c79223eaf09be573e.tar.gz
Ensure we do not interfere with ourselves while parsing
Change-Id: I4e22e91273737321e7dbfa10e50b4ae1f4ee63f9 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
-rw-r--r--plugins/autotest/testcodeparser.cpp49
-rw-r--r--plugins/autotest/testcodeparser.h2
-rw-r--r--plugins/autotest/testtreemodel.cpp2
3 files changed, 36 insertions, 17 deletions
diff --git a/plugins/autotest/testcodeparser.cpp b/plugins/autotest/testcodeparser.cpp
index 0cf2ba5675..982bffbffc 100644
--- a/plugins/autotest/testcodeparser.cpp
+++ b/plugins/autotest/testcodeparser.cpp
@@ -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()
diff --git a/plugins/autotest/testcodeparser.h b/plugins/autotest/testcodeparser.h
index 5a1ad98be4..ecf1caeb84 100644
--- a/plugins/autotest/testcodeparser.h
+++ b/plugins/autotest/testcodeparser.h
@@ -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;
};
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index 4639cbd1e9..2ef7c76c63 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -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,