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

@@ -26,6 +26,7 @@
#include "cppcodemodelinspectordumper.h"
#include "cppmodelmanager.h"
#include "cpptoolsreuse.h"
#include "cppworkingcopy.h"
#include <app/app_version.h>
@@ -501,7 +502,7 @@ static void printIncludeType(QTextStream &out, ProjectExplorer::HeaderPathType t
}
}
void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
void Dumper::dumpProjectInfos(const QList<ProjectInfo::Ptr> &projectInfos)
{
const QByteArray i1 = indent(1);
const QByteArray i2 = indent(2);
@@ -509,18 +510,18 @@ void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
const QByteArray i4 = indent(4);
m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
foreach (const ProjectInfo &info, projectInfos) {
const QPointer<ProjectExplorer::Project> project = info.project();
m_out << i1 << "Project " << project->displayName()
<< " (" << project->projectFilePath().toUserOutput() << "){{{2\n";
foreach (const ProjectInfo::Ptr &info, projectInfos) {
m_out << i1 << "Project " << info->projectName()
<< " (" << info->projectFilePath().toUserOutput() << "){{{2\n";
const QVector<ProjectPart::Ptr> projectParts = info.projectParts();
const QVector<ProjectPart::Ptr> projectParts = info->projectParts();
foreach (const ProjectPart::Ptr &part, projectParts) {
QString projectName = QLatin1String("<None>");
QString projectFilePath = QLatin1String("<None>");
if (ProjectExplorer::Project *project = part->project) {
projectName = project->displayName();
projectFilePath = project->projectFilePath().toUserOutput();
QString projectFilePath = "<None>";
if (part->hasProject()) {
projectFilePath = part->topLevelProject.toUserOutput();
if (const ProjectExplorer::Project * const project = projectForProjectPart(*part))
projectName = project->displayName();
}
if (!part->projectConfigFile.isEmpty())
m_out << i3 << "Project Config File: " << part->projectConfigFile << "\n";