forked from qt-creator/qt-creator
ProjectWindow: Fix crash in TargetSetupPage
Move ownership of the ProjectImporter to the Project. Task-number: QTCREATORBUG-16744 Change-Id: I7fc217ce8058287c5435b259bdc5300a926f8098 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -714,7 +714,7 @@ Utils::MacroExpander *Project::macroExpander() const
|
|||||||
return &d->m_macroExpander;
|
return &d->m_macroExpander;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectImporter *Project::createProjectImporter() const
|
ProjectImporter *Project::projectImporter() const
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public:
|
|||||||
virtual void configureAsExampleProject(const QSet<Core::Id> &platforms);
|
virtual void configureAsExampleProject(const QSet<Core::Id> &platforms);
|
||||||
|
|
||||||
virtual bool requiresTargetPanel() const;
|
virtual bool requiresTargetPanel() const;
|
||||||
virtual ProjectImporter *createProjectImporter() const;
|
virtual ProjectImporter *projectImporter() const;
|
||||||
|
|
||||||
KitMatcher requiredKitMatcher() const;
|
KitMatcher requiredKitMatcher() const;
|
||||||
void setRequiredKitMatcher(const KitMatcher &matcher);
|
void setRequiredKitMatcher(const KitMatcher &matcher);
|
||||||
|
|||||||
@@ -388,6 +388,7 @@ ProjectExplorerPlugin::ProjectExplorerPlugin()
|
|||||||
|
|
||||||
ProjectExplorerPlugin::~ProjectExplorerPlugin()
|
ProjectExplorerPlugin::~ProjectExplorerPlugin()
|
||||||
{
|
{
|
||||||
|
delete dd->m_proWindow; // Needs access to the kit manager.
|
||||||
JsonWizardFactory::destroyAllFactories();
|
JsonWizardFactory::destroyAllFactories();
|
||||||
|
|
||||||
// Force sequence of deletion:
|
// Force sequence of deletion:
|
||||||
@@ -513,7 +514,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
JsonWizardFactory::registerGeneratorFactory(new ScannerGeneratorFactory);
|
JsonWizardFactory::registerGeneratorFactory(new ScannerGeneratorFactory);
|
||||||
|
|
||||||
dd->m_proWindow = new ProjectWindow;
|
dd->m_proWindow = new ProjectWindow;
|
||||||
addAutoReleasedObject(dd->m_proWindow);
|
|
||||||
|
|
||||||
Context projecTreeContext(Constants::C_PROJECT_TREE);
|
Context projecTreeContext(Constants::C_PROJECT_TREE);
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ TargetSetupPageWrapper::TargetSetupPageWrapper(Project *project)
|
|||||||
: m_project(project)
|
: m_project(project)
|
||||||
{
|
{
|
||||||
m_targetSetupPage = new TargetSetupPage(this);
|
m_targetSetupPage = new TargetSetupPage(this);
|
||||||
m_targetSetupPage->setProjectImporter(project->createProjectImporter());
|
|
||||||
m_targetSetupPage->setUseScrollArea(false);
|
m_targetSetupPage->setUseScrollArea(false);
|
||||||
m_targetSetupPage->setProjectPath(project->projectFilePath().toString());
|
m_targetSetupPage->setProjectPath(project->projectFilePath().toString());
|
||||||
m_targetSetupPage->setRequiredKitMatcher(project->requiredKitMatcher());
|
m_targetSetupPage->setRequiredKitMatcher(project->requiredKitMatcher());
|
||||||
@@ -209,7 +208,7 @@ class TargetGroupItemPrivate : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TargetGroupItemPrivate(TargetGroupItem *q, Project *project);
|
TargetGroupItemPrivate(TargetGroupItem *q, Project *project);
|
||||||
~TargetGroupItemPrivate() { /*delete m_importer;*/ }
|
~TargetGroupItemPrivate();
|
||||||
|
|
||||||
void handleRemovedKit(Kit *kit);
|
void handleRemovedKit(Kit *kit);
|
||||||
void handleAddedKit(Kit *kit);
|
void handleAddedKit(Kit *kit);
|
||||||
@@ -224,8 +223,7 @@ public:
|
|||||||
|
|
||||||
TargetGroupItem *q;
|
TargetGroupItem *q;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
QPointer<Project> m_project;
|
Project *m_project;
|
||||||
ProjectImporter *m_importer;
|
|
||||||
|
|
||||||
QPointer<QWidget> m_noKitLabel;
|
QPointer<QWidget> m_noKitLabel;
|
||||||
QPointer<QWidget> m_configurePage;
|
QPointer<QWidget> m_configurePage;
|
||||||
@@ -281,12 +279,13 @@ void TargetGroupItemPrivate::ensureWidget()
|
|||||||
|
|
||||||
void TargetGroupItemPrivate::importTarget(const Utils::FileName &path)
|
void TargetGroupItemPrivate::importTarget(const Utils::FileName &path)
|
||||||
{
|
{
|
||||||
if (!m_importer)
|
ProjectImporter *importer = m_project->projectImporter();
|
||||||
|
if (!importer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Target *target = nullptr;
|
Target *target = nullptr;
|
||||||
BuildConfiguration *bc = nullptr;
|
BuildConfiguration *bc = nullptr;
|
||||||
QList<BuildInfo *> toImport = m_importer->import(path, false);
|
QList<BuildInfo *> toImport = importer->import(path, false);
|
||||||
foreach (BuildInfo *info, toImport) {
|
foreach (BuildInfo *info, toImport) {
|
||||||
target = m_project->target(info->kitId);
|
target = m_project->target(info->kitId);
|
||||||
if (!target) {
|
if (!target) {
|
||||||
@@ -519,7 +518,7 @@ public:
|
|||||||
bool isEnabled() const { return target() != 0; }
|
bool isEnabled() const { return target() != 0; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Project *m_project; // Not owned.
|
QPointer<Project> m_project; // Not owned.
|
||||||
Id m_kitId;
|
Id m_kitId;
|
||||||
int m_currentChild = 1; // Use run page by default.
|
int m_currentChild = 1; // Use run page by default.
|
||||||
};
|
};
|
||||||
@@ -706,13 +705,10 @@ TargetGroupItem::~TargetGroupItem()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetGroupItemPrivate::TargetGroupItemPrivate(TargetGroupItem *q,
|
TargetGroupItemPrivate::TargetGroupItemPrivate(TargetGroupItem *q, Project *project)
|
||||||
Project *project)
|
|
||||||
: q(q), m_project(project)
|
: q(q), m_project(project)
|
||||||
{
|
{
|
||||||
m_importer = project->createProjectImporter();
|
if (project->projectImporter()) {
|
||||||
|
|
||||||
if (m_importer) {
|
|
||||||
auto importAction = new QAction(tr("Import existing build..."), 0);
|
auto importAction = new QAction(tr("Import existing build..."), 0);
|
||||||
QObject::connect(importAction, &QAction::triggered, [this] {
|
QObject::connect(importAction, &QAction::triggered, [this] {
|
||||||
QString dir = m_project->projectDirectory().toString();
|
QString dir = m_project->projectDirectory().toString();
|
||||||
@@ -730,6 +726,11 @@ TargetGroupItemPrivate::TargetGroupItemPrivate(TargetGroupItem *q,
|
|||||||
rebuildContents();
|
rebuildContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TargetGroupItemPrivate::~TargetGroupItemPrivate()
|
||||||
|
{
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant TargetGroupItem::data(int column, int role) const
|
QVariant TargetGroupItem::data(int column, int role) const
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
|
|||||||
@@ -218,9 +218,9 @@ void TargetSetupPage::setPreferredKitMatcher(const KitMatcher &matcher)
|
|||||||
|
|
||||||
TargetSetupPage::~TargetSetupPage()
|
TargetSetupPage::~TargetSetupPage()
|
||||||
{
|
{
|
||||||
|
disconnect();
|
||||||
reset();
|
reset();
|
||||||
delete m_ui;
|
delete m_ui;
|
||||||
delete m_importer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TargetSetupPage::isKitSelected(Core::Id id) const
|
bool TargetSetupPage::isKitSelected(Core::Id id) const
|
||||||
|
|||||||
@@ -298,6 +298,8 @@ QmakeProject::QmakeProject(QmakeManager *manager, const QString &fileName) :
|
|||||||
|
|
||||||
QmakeProject::~QmakeProject()
|
QmakeProject::~QmakeProject()
|
||||||
{
|
{
|
||||||
|
delete m_projectImporter;
|
||||||
|
m_projectImporter = nullptr;
|
||||||
m_codeModelFuture.cancel();
|
m_codeModelFuture.cancel();
|
||||||
m_asyncUpdateState = ShuttingDown;
|
m_asyncUpdateState = ShuttingDown;
|
||||||
|
|
||||||
@@ -1613,9 +1615,11 @@ void QmakeProject::emitBuildDirectoryInitialized()
|
|||||||
emit buildDirectoryInitialized();
|
emit buildDirectoryInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectImporter *QmakeProject::createProjectImporter() const
|
ProjectImporter *QmakeProject::projectImporter() const
|
||||||
{
|
{
|
||||||
return new QmakeProjectImporter(projectFilePath().toString());
|
if (!m_projectImporter)
|
||||||
|
m_projectImporter = new QmakeProjectImporter(projectFilePath().toString());
|
||||||
|
return m_projectImporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmakeProject::AsyncUpdateState QmakeProject::asyncUpdateState() const
|
QmakeProject::AsyncUpdateState QmakeProject::asyncUpdateState() const
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public:
|
|||||||
void emitBuildDirectoryInitialized();
|
void emitBuildDirectoryInitialized();
|
||||||
static void proFileParseError(const QString &errorMessage);
|
static void proFileParseError(const QString &errorMessage);
|
||||||
|
|
||||||
ProjectExplorer::ProjectImporter *createProjectImporter() const override;
|
ProjectExplorer::ProjectImporter *projectImporter() const override;
|
||||||
|
|
||||||
enum AsyncUpdateState { Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown };
|
enum AsyncUpdateState { Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown };
|
||||||
AsyncUpdateState asyncUpdateState() const;
|
AsyncUpdateState asyncUpdateState() const;
|
||||||
@@ -203,6 +203,7 @@ private:
|
|||||||
Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher = nullptr;
|
Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher = nullptr;
|
||||||
|
|
||||||
ProjectExplorer::Target *m_activeTarget = nullptr;
|
ProjectExplorer::Target *m_activeTarget = nullptr;
|
||||||
|
mutable ProjectExplorer::ProjectImporter *m_projectImporter = nullptr;
|
||||||
|
|
||||||
friend class Internal::QmakeProjectFile;
|
friend class Internal::QmakeProjectFile;
|
||||||
friend class Internal::QmakeProjectConfigWidget;
|
friend class Internal::QmakeProjectConfigWidget;
|
||||||
|
|||||||
Reference in New Issue
Block a user