forked from qt-creator/qt-creator
AutoTest: Avoid fetching WorkingCopy from multiple threads
Instead fetch it once before starting asynchronous processing.
Backported from 72e6dd2ab1
on master.
Change-Id: If159311d1ce244c39482acb2ed0d7e33907a2933
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
committed by
Eike Ziller
parent
083b1175c9
commit
ccda65bf83
@@ -156,13 +156,13 @@ void TestCodeParser::updateTestTree()
|
|||||||
|
|
||||||
/****** scan for QTest related stuff helpers ******/
|
/****** scan for QTest related stuff helpers ******/
|
||||||
|
|
||||||
|
static CppTools::WorkingCopy s_workingCopy;
|
||||||
|
|
||||||
static QByteArray getFileContent(QString filePath)
|
static QByteArray getFileContent(QString filePath)
|
||||||
{
|
{
|
||||||
QByteArray fileContent;
|
QByteArray fileContent;
|
||||||
CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
|
if (s_workingCopy.contains(filePath)) {
|
||||||
CppTools::WorkingCopy wc = cppMM->workingCopy();
|
fileContent = s_workingCopy.source(filePath);
|
||||||
if (wc.contains(filePath)) {
|
|
||||||
fileContent = wc.source(filePath);
|
|
||||||
} else {
|
} else {
|
||||||
QString error;
|
QString error;
|
||||||
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
||||||
@@ -751,6 +751,9 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
|
|||||||
m_model->markForRemoval(filePath);
|
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);
|
QFuture<TestParseResult> future = Utils::runAsync(&performParse, list, testCaseNames);
|
||||||
m_futureWatcher.setFuture(future);
|
m_futureWatcher.setFuture(future);
|
||||||
if (list.size() > 5) {
|
if (list.size() > 5) {
|
||||||
@@ -793,12 +796,14 @@ void TestCodeParser::onFinished()
|
|||||||
} else {
|
} else {
|
||||||
qCDebug(LOG) << "emitting parsingFinished"
|
qCDebug(LOG) << "emitting parsingFinished"
|
||||||
<< "(onFinished, FullParse, nothing postponed, parsing succeeded)";
|
<< "(onFinished, FullParse, nothing postponed, parsing succeeded)";
|
||||||
|
s_workingCopy = CppTools::WorkingCopy();
|
||||||
emit parsingFinished();
|
emit parsingFinished();
|
||||||
}
|
}
|
||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
break;
|
break;
|
||||||
case Disabled: // can happen if all Test related widgets become hidden while parsing
|
case Disabled: // can happen if all Test related widgets become hidden while parsing
|
||||||
qCDebug(LOG) << "emitting parsingFinished (onFinished, Disabled)";
|
qCDebug(LOG) << "emitting parsingFinished (onFinished, Disabled)";
|
||||||
|
s_workingCopy = CppTools::WorkingCopy();
|
||||||
emit parsingFinished();
|
emit parsingFinished();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -827,6 +832,7 @@ void TestCodeParser::onPartialParsingFinished()
|
|||||||
} else if (!m_singleShotScheduled) {
|
} else if (!m_singleShotScheduled) {
|
||||||
qCDebug(LOG) << "emitting parsingFinished"
|
qCDebug(LOG) << "emitting parsingFinished"
|
||||||
<< "(onPartialParsingFinished, nothing postponed, not dirty)";
|
<< "(onPartialParsingFinished, nothing postponed, not dirty)";
|
||||||
|
s_workingCopy = CppTools::WorkingCopy();
|
||||||
emit parsingFinished();
|
emit parsingFinished();
|
||||||
} else {
|
} else {
|
||||||
qCDebug(LOG) << "not emitting parsingFinished"
|
qCDebug(LOG) << "not emitting parsingFinished"
|
||||||
|
Reference in New Issue
Block a user