forked from qt-creator/qt-creator
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:
@@ -237,7 +237,7 @@ bool TestCase::waitUntilProjectIsFullyOpened(Project *project, int timeOutInMs)
|
||||
[project]() {
|
||||
return SessionManager::startupBuildSystem()
|
||||
&& !SessionManager::startupBuildSystem()->isParsing()
|
||||
&& CppModelManager::instance()->projectInfo(project).isValid();
|
||||
&& CppModelManager::instance()->projectInfo(project);
|
||||
},
|
||||
timeOutInMs);
|
||||
}
|
||||
@@ -278,14 +278,14 @@ ProjectOpenerAndCloser::~ProjectOpenerAndCloser()
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
ProjectInfo ProjectOpenerAndCloser::open(const QString &projectFile, bool configureAsExampleProject,
|
||||
Kit *kit)
|
||||
ProjectInfo::Ptr ProjectOpenerAndCloser::open(const QString &projectFile,
|
||||
bool configureAsExampleProject, Kit *kit)
|
||||
{
|
||||
ProjectExplorerPlugin::OpenProjectResult result =
|
||||
ProjectExplorerPlugin::openProject(FilePath::fromString(projectFile));
|
||||
if (!result) {
|
||||
qWarning() << result.errorMessage() << result.alreadyOpen();
|
||||
return ProjectInfo();
|
||||
return {};
|
||||
}
|
||||
|
||||
Project *project = result.project();
|
||||
@@ -297,7 +297,7 @@ ProjectInfo ProjectOpenerAndCloser::open(const QString &projectFile, bool config
|
||||
return CppModelManager::instance()->projectInfo(project);
|
||||
}
|
||||
|
||||
return ProjectInfo();
|
||||
return {};
|
||||
}
|
||||
|
||||
TemporaryDir::TemporaryDir()
|
||||
|
||||
Reference in New Issue
Block a user