Commit ccda65bf authored by Christian Stenger's avatar Christian Stenger Committed by Eike Ziller

AutoTest: Avoid fetching WorkingCopy from multiple threads

Instead fetch it once before starting asynchronous processing.
Backported from 72e6dd2a on master.

Change-Id: If159311d1ce244c39482acb2ed0d7e33907a2933
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent 083b1175
......@@ -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"
......
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