forked from qt-creator/qt-creator
BuildStepList: Pass ProjectConfiguration into c'tor
Instead of relying on parent-child qobject hierarchy. Add explicit BuildStepList::projectConfiguration() getter. Add explicit Target arg into ProjectConfiguration c'tor and avoid qobject_cast. Change-Id: I0b3105f7f8aea950e9679857887baffe9b321a33 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -127,10 +127,10 @@ class BuildConfigurationPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BuildConfigurationPrivate(BuildConfiguration *bc)
|
BuildConfigurationPrivate(BuildConfiguration *bc)
|
||||||
: m_buildSteps(bc, Constants::BUILDSTEPS_BUILD),
|
: m_buildSteps(bc, Constants::BUILDSTEPS_BUILD)
|
||||||
m_cleanSteps(bc, Constants::BUILDSTEPS_CLEAN),
|
, m_cleanSteps(bc, Constants::BUILDSTEPS_CLEAN)
|
||||||
m_buildDirectoryAspect(bc, bc),
|
, m_buildDirectoryAspect(bc, bc)
|
||||||
m_tooltipAspect(bc)
|
, m_tooltipAspect(bc)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool m_clearSystemEnvironment = false;
|
bool m_clearSystemEnvironment = false;
|
||||||
@@ -157,10 +157,9 @@ public:
|
|||||||
} // Internal
|
} // Internal
|
||||||
|
|
||||||
BuildConfiguration::BuildConfiguration(Target *target, Utils::Id id)
|
BuildConfiguration::BuildConfiguration(Target *target, Utils::Id id)
|
||||||
: ProjectConfiguration(target, id), d(new Internal::BuildConfigurationPrivate(this))
|
: ProjectConfiguration(target, target, id)
|
||||||
|
, d(new Internal::BuildConfigurationPrivate(this))
|
||||||
{
|
{
|
||||||
QTC_CHECK(target && target == this->target());
|
|
||||||
|
|
||||||
MacroExpander *expander = macroExpander();
|
MacroExpander *expander = macroExpander();
|
||||||
expander->setDisplayName(Tr::tr("Build Settings"));
|
expander->setDisplayName(Tr::tr("Build Settings"));
|
||||||
expander->setAccumulating(true);
|
expander->setAccumulating(true);
|
||||||
|
@@ -111,10 +111,9 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
static QList<BuildStepFactory *> g_buildStepFactories;
|
static QList<BuildStepFactory *> g_buildStepFactories;
|
||||||
|
|
||||||
BuildStep::BuildStep(BuildStepList *bsl, Id id) :
|
BuildStep::BuildStep(BuildStepList *bsl, Id id)
|
||||||
ProjectConfiguration(bsl, id)
|
: ProjectConfiguration(bsl, bsl->target(), id)
|
||||||
{
|
{
|
||||||
QTC_CHECK(bsl->target() && bsl->target() == this->target());
|
|
||||||
connect(this, &ProjectConfiguration::displayNameChanged,
|
connect(this, &ProjectConfiguration::displayNameChanged,
|
||||||
this, &BuildStep::updateSummary);
|
this, &BuildStep::updateSummary);
|
||||||
// m_displayName = step->displayName();
|
// m_displayName = step->displayName();
|
||||||
@@ -346,7 +345,7 @@ bool BuildStepFactory::canHandle(BuildStepList *bsl) const
|
|||||||
if (!m_supportedStepLists.isEmpty() && !m_supportedStepLists.contains(bsl->id()))
|
if (!m_supportedStepLists.isEmpty() && !m_supportedStepLists.contains(bsl->id()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto config = qobject_cast<ProjectConfiguration *>(bsl->parent());
|
ProjectConfiguration *config = bsl->projectConfiguration();
|
||||||
|
|
||||||
if (!m_supportedDeviceTypes.isEmpty()) {
|
if (!m_supportedDeviceTypes.isEmpty()) {
|
||||||
Target *target = bsl->target();
|
Target *target = bsl->target();
|
||||||
|
@@ -19,13 +19,10 @@ namespace ProjectExplorer {
|
|||||||
const char STEPS_COUNT_KEY[] = "ProjectExplorer.BuildStepList.StepsCount";
|
const char STEPS_COUNT_KEY[] = "ProjectExplorer.BuildStepList.StepsCount";
|
||||||
const char STEPS_PREFIX[] = "ProjectExplorer.BuildStepList.Step.";
|
const char STEPS_PREFIX[] = "ProjectExplorer.BuildStepList.Step.";
|
||||||
|
|
||||||
BuildStepList::BuildStepList(QObject *parent, Utils::Id id)
|
BuildStepList::BuildStepList(ProjectConfiguration *config, Utils::Id id)
|
||||||
: QObject(parent), m_id(id)
|
: QObject(config), m_projectConfiguration(config), m_id(id)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(parent, return);
|
QTC_CHECK(config);
|
||||||
QTC_ASSERT(parent->parent(), return);
|
|
||||||
m_target = qobject_cast<Target *>(parent->parent());
|
|
||||||
QTC_ASSERT(m_target, return);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildStepList::~BuildStepList()
|
BuildStepList::~BuildStepList()
|
||||||
@@ -39,6 +36,11 @@ void BuildStepList::clear()
|
|||||||
m_steps.clear();
|
m_steps.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Target *BuildStepList::target() const
|
||||||
|
{
|
||||||
|
return m_projectConfiguration->target();
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap BuildStepList::toMap() const
|
QVariantMap BuildStepList::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class BuildStep;
|
class BuildStep;
|
||||||
|
class ProjectConfiguration;
|
||||||
class Target;
|
class Target;
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT BuildStepList : public QObject
|
class PROJECTEXPLORER_EXPORT BuildStepList : public QObject
|
||||||
@@ -20,7 +21,7 @@ class PROJECTEXPLORER_EXPORT BuildStepList : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BuildStepList(QObject *parent, Utils::Id id);
|
explicit BuildStepList(ProjectConfiguration *config, Utils::Id id);
|
||||||
~BuildStepList() override;
|
~BuildStepList() override;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
@@ -56,7 +57,8 @@ public:
|
|||||||
void moveStepUp(int position);
|
void moveStepUp(int position);
|
||||||
BuildStep *at(int position) const;
|
BuildStep *at(int position) const;
|
||||||
|
|
||||||
Target *target() { return m_target; }
|
ProjectConfiguration *projectConfiguration() const { return m_projectConfiguration; }
|
||||||
|
Target *target() const;
|
||||||
|
|
||||||
QVariantMap toMap() const;
|
QVariantMap toMap() const;
|
||||||
bool fromMap(const QVariantMap &map);
|
bool fromMap(const QVariantMap &map);
|
||||||
@@ -71,7 +73,7 @@ signals:
|
|||||||
void stepMoved(int from, int to);
|
void stepMoved(int from, int to);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Target *m_target;
|
ProjectConfiguration *m_projectConfiguration;
|
||||||
Utils::Id m_id;
|
Utils::Id m_id;
|
||||||
QList<BuildStep *> m_steps;
|
QList<BuildStep *> m_steps;
|
||||||
};
|
};
|
||||||
|
@@ -26,10 +26,9 @@ const char USES_DEPLOYMENT_DATA[] = "ProjectExplorer.DeployConfiguration.CustomD
|
|||||||
const char DEPLOYMENT_DATA[] = "ProjectExplorer.DeployConfiguration.CustomData";
|
const char DEPLOYMENT_DATA[] = "ProjectExplorer.DeployConfiguration.CustomData";
|
||||||
|
|
||||||
DeployConfiguration::DeployConfiguration(Target *target, Id id)
|
DeployConfiguration::DeployConfiguration(Target *target, Id id)
|
||||||
: ProjectConfiguration(target, id),
|
: ProjectConfiguration(target, target, id)
|
||||||
m_stepList(this, Constants::BUILDSTEPS_DEPLOY)
|
, m_stepList(this, Constants::BUILDSTEPS_DEPLOY)
|
||||||
{
|
{
|
||||||
QTC_CHECK(target && target == this->target());
|
|
||||||
//: Default DeployConfiguration display name
|
//: Default DeployConfiguration display name
|
||||||
setDefaultDisplayName(Tr::tr("Deploy locally"));
|
setDefaultDisplayName(Tr::tr("Deploy locally"));
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "projectconfiguration.h"
|
#include "projectconfiguration.h"
|
||||||
|
|
||||||
#include "kitinformation.h"
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -17,20 +16,15 @@ const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayNam
|
|||||||
|
|
||||||
// ProjectConfiguration
|
// ProjectConfiguration
|
||||||
|
|
||||||
ProjectConfiguration::ProjectConfiguration(QObject *parent, Utils::Id id)
|
ProjectConfiguration::ProjectConfiguration(QObject *parent, Target *target, Utils::Id id)
|
||||||
: AspectContainer(parent)
|
: AspectContainer(parent)
|
||||||
|
, m_target(target)
|
||||||
, m_id(id)
|
, m_id(id)
|
||||||
{
|
{
|
||||||
QTC_CHECK(parent);
|
QTC_CHECK(parent);
|
||||||
|
QTC_CHECK(target);
|
||||||
QTC_CHECK(id.isValid());
|
QTC_CHECK(id.isValid());
|
||||||
setObjectName(id.toString());
|
setObjectName(id.toString());
|
||||||
|
|
||||||
for (QObject *obj = this; obj; obj = obj->parent()) {
|
|
||||||
m_target = qobject_cast<Target *>(obj);
|
|
||||||
if (m_target)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QTC_CHECK(m_target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectConfiguration::~ProjectConfiguration() = default;
|
ProjectConfiguration::~ProjectConfiguration() = default;
|
||||||
|
@@ -26,7 +26,7 @@ class PROJECTEXPLORER_EXPORT ProjectConfiguration : public Utils::AspectContaine
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit ProjectConfiguration(QObject *parent, Utils::Id id);
|
explicit ProjectConfiguration(QObject *parent, Target *target, Utils::Id id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~ProjectConfiguration() override;
|
~ProjectConfiguration() override;
|
||||||
|
@@ -160,9 +160,8 @@ void GlobalOrProjectAspect::resetProjectToGlobalSettings()
|
|||||||
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
|
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
|
||||||
|
|
||||||
RunConfiguration::RunConfiguration(Target *target, Utils::Id id)
|
RunConfiguration::RunConfiguration(Target *target, Utils::Id id)
|
||||||
: ProjectConfiguration(target, id)
|
: ProjectConfiguration(target, target, id)
|
||||||
{
|
{
|
||||||
QTC_CHECK(target && target == this->target());
|
|
||||||
forceDisplayNameSerialization();
|
forceDisplayNameSerialization();
|
||||||
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
|
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user