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:
@@ -203,8 +203,11 @@ void CppcheckTool::check(const Utils::FilePaths &files)
|
||||
if (filtered.isEmpty())
|
||||
return;
|
||||
|
||||
const CppTools::ProjectInfo info = CppTools::CppModelManager::instance()->projectInfo(m_project);
|
||||
const QVector<CppTools::ProjectPart::Ptr> parts = info.projectParts();
|
||||
const CppTools::ProjectInfo::Ptr info
|
||||
= CppTools::CppModelManager::instance()->projectInfo(m_project);
|
||||
if (!info)
|
||||
return;
|
||||
const QVector<CppTools::ProjectPart::Ptr> parts = info->projectParts();
|
||||
if (parts.size() == 1) {
|
||||
QTC_ASSERT(parts.first(), return);
|
||||
addToQueue(filtered, *parts.first());
|
||||
|
||||
@@ -76,8 +76,9 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors)
|
||||
return;
|
||||
|
||||
using CppModelManager = CppTools::CppModelManager;
|
||||
const CppTools::ProjectInfo info = CppModelManager::instance()->projectInfo(m_currentProject);
|
||||
if (!info.isValid())
|
||||
const CppTools::ProjectInfo::Ptr info
|
||||
= CppModelManager::instance()->projectInfo(m_currentProject);
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
const QList<Core::IEditor *> editorList = !editors.isEmpty()
|
||||
@@ -99,7 +100,7 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors)
|
||||
continue;
|
||||
|
||||
const QString &pathString = path.toString();
|
||||
if (!info.sourceFiles().contains(pathString))
|
||||
if (!info->sourceFiles().contains(pathString))
|
||||
continue;
|
||||
|
||||
connect(document, &Core::IDocument::aboutToReload,
|
||||
|
||||
Reference in New Issue
Block a user