CppTools: Turn some classes into pure value types

ProjectInfo, ProjectPart and ProjectUpdateInfo used to carry pointers
to Project and/or Toolchain, even though they were used in contexts
where these pointers were either unsafe to access or not guaranteed to
be valid anymore, which made their use difficult and error-prone.
We turn these classes into pure value types by copying in all relevant
information before the first async operation takes place.

Fixes: QTCREATORBUG-25678
Change-Id: I1914b0dbda6c7dfba6c95e5e92f2d69977755590
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Christian Kandeler
2021-05-07 16:10:07 +02:00
parent 3143ba79e3
commit 33108795d6
61 changed files with 1086 additions and 958 deletions

View File

@@ -109,8 +109,7 @@ void AutoTestUnitTests::testCodeParser()
QFETCH(int, expectedDataTagsCount);
CppTools::Tests::ProjectOpenerAndCloser projectManager;
const CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true, m_kit);
QVERIFY(projectInfo.isValid());
QVERIFY(projectManager.open(projectFilePath, true, m_kit));
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
@@ -160,8 +159,7 @@ void AutoTestUnitTests::testCodeParserSwitchStartup()
CppTools::Tests::ProjectOpenerAndCloser projectManager;
for (int i = 0; i < projectFilePaths.size(); ++i) {
qDebug() << "Opening project" << projectFilePaths.at(i);
CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePaths.at(i), true, m_kit);
QVERIFY(projectInfo.isValid());
QVERIFY(projectManager.open(projectFilePaths.at(i), true, m_kit));
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
@@ -208,8 +206,7 @@ void AutoTestUnitTests::testCodeParserGTest()
QFETCH(QString, projectFilePath);
CppTools::Tests::ProjectOpenerAndCloser projectManager;
CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true, m_kit);
QVERIFY(projectInfo.isValid());
QVERIFY(projectManager.open(projectFilePath, true, m_kit));
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
@@ -258,8 +255,9 @@ void AutoTestUnitTests::testCodeParserBoostTest()
QFETCH(QString, projectFilePath);
QFETCH(QString, extension);
CppTools::Tests::ProjectOpenerAndCloser projectManager;
CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true, m_kit);
QVERIFY(projectInfo.isValid());
const CppTools::ProjectInfo::Ptr projectInfo
= projectManager.open(projectFilePath, true, m_kit);
QVERIFY(projectInfo);
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
@@ -268,10 +266,7 @@ void AutoTestUnitTests::testCodeParserBoostTest()
QCOMPARE(m_model->boostTestNamesCount(), 5);
auto project = projectInfo.project();
QVERIFY(project);
const Utils::FilePath basePath = project->projectFilePath().absolutePath();
const Utils::FilePath basePath = projectInfo->projectRoot();
QVERIFY(!basePath.isEmpty());
QMap<QString, int> expectedSuitesAndTests;