forked from qt-creator/qt-creator
CppEditor/CppTools: Tests: Fix potential race condition
...when updating the code model. Change-Id: Ifc55b7d0bb795b9cfd72465990991bc2cc907846 Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
dad0140134
commit
9b41023b68
@@ -209,20 +209,12 @@ void TestCase::init(const QStringList &includePaths)
|
||||
QStringList filePaths;
|
||||
foreach (const TestDocumentPtr &testFile, testFiles)
|
||||
filePaths << testFile->filePath();
|
||||
cmm->updateSourceFiles(filePaths);
|
||||
|
||||
// Wait for the parser in the future to give us the document
|
||||
QStringList filePathsNotYetInSnapshot(filePaths);
|
||||
forever {
|
||||
Snapshot snapshot = cmm->snapshot();
|
||||
foreach (const QString &filePath, filePathsNotYetInSnapshot) {
|
||||
if (snapshot.contains(filePath))
|
||||
filePathsNotYetInSnapshot.removeOne(filePath);
|
||||
}
|
||||
if (filePathsNotYetInSnapshot.isEmpty())
|
||||
break;
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
cmm->updateSourceFiles(filePaths).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
const Snapshot snapshot = cmm->snapshot();
|
||||
QVERIFY(!snapshot.isEmpty());
|
||||
foreach (const QString &filePath, filePaths)
|
||||
QVERIFY(snapshot.contains(filePath));
|
||||
|
||||
// Open Files
|
||||
foreach (TestDocumentPtr testFile, testFiles) {
|
||||
|
||||
Reference in New Issue
Block a user