summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2016-06-20 07:44:02 +0200
committerEike Ziller <eike.ziller@qt.io>2016-06-20 13:30:21 +0000
commitccda65bf838786b705a81d9dba602c2bc0d62242 (patch)
treec6601898e84b268f1df1bd0a806fef326aa7fd65
parent083b1175c9a01e0fa895fa47ecff1edd7df16ae0 (diff)
downloadqt-creator-ccda65bf838786b705a81d9dba602c2bc0d62242.tar.gz
AutoTest: Avoid fetching WorkingCopy from multiple threads
Instead fetch it once before starting asynchronous processing. Backported from 72e6dd2ab102ddb45ab3de12f61ab1d21c41e6eb on master. Change-Id: If159311d1ce244c39482acb2ed0d7e33907a2933 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
-rw-r--r--src/plugins/autotest/testcodeparser.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp
index 31dd747389..d2f4ba8d3f 100644
--- a/src/plugins/autotest/testcodeparser.cpp
+++ b/src/plugins/autotest/testcodeparser.cpp
@@ -156,13 +156,13 @@ void TestCodeParser::updateTestTree()
/****** scan for QTest related stuff helpers ******/
+static CppTools::WorkingCopy s_workingCopy;
+
static QByteArray getFileContent(QString filePath)
{
QByteArray fileContent;
- CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
- CppTools::WorkingCopy wc = cppMM->workingCopy();
- if (wc.contains(filePath)) {
- fileContent = wc.source(filePath);
+ if (s_workingCopy.contains(filePath)) {
+ fileContent = s_workingCopy.source(filePath);
} else {
QString error;
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
@@ -751,6 +751,9 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
m_model->markForRemoval(filePath);
}
+ // fetch working copy before starting asynchronously processing
+ s_workingCopy = CppTools::CppModelManager::instance()->workingCopy();
+
QFuture<TestParseResult> future = Utils::runAsync(&performParse, list, testCaseNames);
m_futureWatcher.setFuture(future);
if (list.size() > 5) {
@@ -793,12 +796,14 @@ void TestCodeParser::onFinished()
} else {
qCDebug(LOG) << "emitting parsingFinished"
<< "(onFinished, FullParse, nothing postponed, parsing succeeded)";
+ s_workingCopy = CppTools::WorkingCopy();
emit parsingFinished();
}
m_dirty = false;
break;
case Disabled: // can happen if all Test related widgets become hidden while parsing
qCDebug(LOG) << "emitting parsingFinished (onFinished, Disabled)";
+ s_workingCopy = CppTools::WorkingCopy();
emit parsingFinished();
break;
default:
@@ -827,6 +832,7 @@ void TestCodeParser::onPartialParsingFinished()
} else if (!m_singleShotScheduled) {
qCDebug(LOG) << "emitting parsingFinished"
<< "(onPartialParsingFinished, nothing postponed, not dirty)";
+ s_workingCopy = CppTools::WorkingCopy();
emit parsingFinished();
} else {
qCDebug(LOG) << "not emitting parsingFinished"