forked from qt-creator/qt-creator
CppEditor: Catch another project pointer access from a thread
Amends 33108795d6
.
Fixes: QTCREATORBUG-27044
Change-Id: I53d716355b0784841fd8d965c8af14fe321c33de
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -120,7 +120,7 @@ BaseEditorDocumentParser::Ptr BaseEditorDocumentParser::get(const QString &fileP
|
|||||||
ProjectPartInfo BaseEditorDocumentParser::determineProjectPart(const QString &filePath,
|
ProjectPartInfo BaseEditorDocumentParser::determineProjectPart(const QString &filePath,
|
||||||
const QString &preferredProjectPartId,
|
const QString &preferredProjectPartId,
|
||||||
const ProjectPartInfo ¤tProjectPartInfo,
|
const ProjectPartInfo ¤tProjectPartInfo,
|
||||||
const ProjectExplorer::Project *activeProject,
|
const Utils::FilePath &activeProject,
|
||||||
Utils::Language languagePreference,
|
Utils::Language languagePreference,
|
||||||
bool projectsUpdated)
|
bool projectsUpdated)
|
||||||
{
|
{
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
#include "cppworkingcopy.h"
|
#include "cppworkingcopy.h"
|
||||||
#include "projectpart.h"
|
#include "projectpart.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
|
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
@@ -65,14 +67,14 @@ public:
|
|||||||
Utils::Language languagePreference,
|
Utils::Language languagePreference,
|
||||||
bool projectsUpdated)
|
bool projectsUpdated)
|
||||||
: workingCopy(workingCopy)
|
: workingCopy(workingCopy)
|
||||||
, activeProject(activeProject)
|
, activeProject(activeProject ? activeProject->projectFilePath() : Utils::FilePath())
|
||||||
, languagePreference(languagePreference)
|
, languagePreference(languagePreference)
|
||||||
, projectsUpdated(projectsUpdated)
|
, projectsUpdated(projectsUpdated)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkingCopy workingCopy;
|
WorkingCopy workingCopy;
|
||||||
const ProjectExplorer::Project *activeProject = nullptr;
|
const Utils::FilePath activeProject;
|
||||||
Utils::Language languagePreference = Utils::Language::Cxx;
|
Utils::Language languagePreference = Utils::Language::Cxx;
|
||||||
bool projectsUpdated = false;
|
bool projectsUpdated = false;
|
||||||
};
|
};
|
||||||
@@ -104,7 +106,7 @@ protected:
|
|||||||
static ProjectPartInfo determineProjectPart(const QString &filePath,
|
static ProjectPartInfo determineProjectPart(const QString &filePath,
|
||||||
const QString &preferredProjectPartId,
|
const QString &preferredProjectPartId,
|
||||||
const ProjectPartInfo ¤tProjectPartInfo,
|
const ProjectPartInfo ¤tProjectPartInfo,
|
||||||
const ProjectExplorer::Project *activeProject,
|
const Utils::FilePath &activeProject,
|
||||||
Utils::Language languagePreference,
|
Utils::Language languagePreference,
|
||||||
bool projectsUpdated);
|
bool projectsUpdated);
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
ProjectPartPrioritizer(const QList<ProjectPart::ConstPtr> &projectParts,
|
ProjectPartPrioritizer(const QList<ProjectPart::ConstPtr> &projectParts,
|
||||||
const QString &preferredProjectPartId,
|
const QString &preferredProjectPartId,
|
||||||
const ProjectExplorer::Project *activeProject,
|
const Utils::FilePath &activeProject,
|
||||||
Language languagePreference,
|
Language languagePreference,
|
||||||
bool areProjectPartsFromDependencies)
|
bool areProjectPartsFromDependencies)
|
||||||
: m_preferredProjectPartId(preferredProjectPartId)
|
: m_preferredProjectPartId(preferredProjectPartId)
|
||||||
@@ -124,7 +124,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_preferredProjectPartId;
|
const QString m_preferredProjectPartId;
|
||||||
const ProjectExplorer::Project *m_activeProject = nullptr;
|
const Utils::FilePath m_activeProject;
|
||||||
Language m_languagePreference = Language::Cxx;
|
Language m_languagePreference = Language::Cxx;
|
||||||
|
|
||||||
// Results
|
// Results
|
||||||
@@ -134,7 +134,7 @@ private:
|
|||||||
ProjectPartInfo ProjectPartChooser::choose(const QString &filePath,
|
ProjectPartInfo ProjectPartChooser::choose(const QString &filePath,
|
||||||
const ProjectPartInfo ¤tProjectPartInfo,
|
const ProjectPartInfo ¤tProjectPartInfo,
|
||||||
const QString &preferredProjectPartId,
|
const QString &preferredProjectPartId,
|
||||||
const ProjectExplorer::Project *activeProject,
|
const Utils::FilePath &activeProject,
|
||||||
Language languagePreference,
|
Language languagePreference,
|
||||||
bool projectsUpdated) const
|
bool projectsUpdated) const
|
||||||
{
|
{
|
||||||
|
@@ -50,7 +50,7 @@ public:
|
|||||||
ProjectPartInfo choose(const QString &filePath,
|
ProjectPartInfo choose(const QString &filePath,
|
||||||
const ProjectPartInfo ¤tProjectPartInfo,
|
const ProjectPartInfo ¤tProjectPartInfo,
|
||||||
const QString &preferredProjectPartId,
|
const QString &preferredProjectPartId,
|
||||||
const ProjectExplorer::Project *activeProject,
|
const Utils::FilePath &activeProject,
|
||||||
Utils::Language languagePreference,
|
Utils::Language languagePreference,
|
||||||
bool projectsUpdated) const;
|
bool projectsUpdated) const;
|
||||||
|
|
||||||
|
@@ -60,8 +60,11 @@ public:
|
|||||||
|
|
||||||
const ProjectPartInfo choose()
|
const ProjectPartInfo choose()
|
||||||
{
|
{
|
||||||
|
const Project * const project = projectMap.value(activeProject).get();
|
||||||
|
const Utils::FilePath projectFilePath = project ? project->projectFilePath()
|
||||||
|
: Utils::FilePath();
|
||||||
return chooser.choose(filePath, currentProjectPartInfo, preferredProjectPartId,
|
return chooser.choose(filePath, currentProjectPartInfo, preferredProjectPartId,
|
||||||
projectMap.value(activeProject).get(),
|
projectFilePath,
|
||||||
languagePreference, projectsChanged);
|
languagePreference, projectsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,7 +57,12 @@ QString ProjectPart::projectFileLocation() const
|
|||||||
|
|
||||||
bool ProjectPart::belongsToProject(const ProjectExplorer::Project *project) const
|
bool ProjectPart::belongsToProject(const ProjectExplorer::Project *project) const
|
||||||
{
|
{
|
||||||
return project ? topLevelProject == project->projectFilePath() : !hasProject();
|
return belongsToProject(project ? project->projectFilePath() : Utils::FilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProjectPart::belongsToProject(const Utils::FilePath &project) const
|
||||||
|
{
|
||||||
|
return topLevelProject == project;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ProjectPart::readProjectConfigFile(const QString &projectConfigFile)
|
QByteArray ProjectPart::readProjectConfigFile(const QString &projectConfigFile)
|
||||||
|
@@ -75,6 +75,7 @@ public:
|
|||||||
QString projectFileLocation() const;
|
QString projectFileLocation() const;
|
||||||
bool hasProject() const { return !topLevelProject.isEmpty(); }
|
bool hasProject() const { return !topLevelProject.isEmpty(); }
|
||||||
bool belongsToProject(const ProjectExplorer::Project *project) const;
|
bool belongsToProject(const ProjectExplorer::Project *project) const;
|
||||||
|
bool belongsToProject(const Utils::FilePath &project) const;
|
||||||
|
|
||||||
static QByteArray readProjectConfigFile(const QString &projectConfigFile);
|
static QByteArray readProjectConfigFile(const QString &projectConfigFile);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user