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:
|
||||
BuildConfigurationPrivate(BuildConfiguration *bc)
|
||||
: m_buildSteps(bc, Constants::BUILDSTEPS_BUILD),
|
||||
m_cleanSteps(bc, Constants::BUILDSTEPS_CLEAN),
|
||||
m_buildDirectoryAspect(bc, bc),
|
||||
m_tooltipAspect(bc)
|
||||
: m_buildSteps(bc, Constants::BUILDSTEPS_BUILD)
|
||||
, m_cleanSteps(bc, Constants::BUILDSTEPS_CLEAN)
|
||||
, m_buildDirectoryAspect(bc, bc)
|
||||
, m_tooltipAspect(bc)
|
||||
{}
|
||||
|
||||
bool m_clearSystemEnvironment = false;
|
||||
@@ -157,10 +157,9 @@ public:
|
||||
} // Internal
|
||||
|
||||
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();
|
||||
expander->setDisplayName(Tr::tr("Build Settings"));
|
||||
expander->setAccumulating(true);
|
||||
|
@@ -111,10 +111,9 @@ namespace ProjectExplorer {
|
||||
|
||||
static QList<BuildStepFactory *> g_buildStepFactories;
|
||||
|
||||
BuildStep::BuildStep(BuildStepList *bsl, Id id) :
|
||||
ProjectConfiguration(bsl, id)
|
||||
BuildStep::BuildStep(BuildStepList *bsl, Id id)
|
||||
: ProjectConfiguration(bsl, bsl->target(), id)
|
||||
{
|
||||
QTC_CHECK(bsl->target() && bsl->target() == this->target());
|
||||
connect(this, &ProjectConfiguration::displayNameChanged,
|
||||
this, &BuildStep::updateSummary);
|
||||
// m_displayName = step->displayName();
|
||||
@@ -346,7 +345,7 @@ bool BuildStepFactory::canHandle(BuildStepList *bsl) const
|
||||
if (!m_supportedStepLists.isEmpty() && !m_supportedStepLists.contains(bsl->id()))
|
||||
return false;
|
||||
|
||||
auto config = qobject_cast<ProjectConfiguration *>(bsl->parent());
|
||||
ProjectConfiguration *config = bsl->projectConfiguration();
|
||||
|
||||
if (!m_supportedDeviceTypes.isEmpty()) {
|
||||
Target *target = bsl->target();
|
||||
|
@@ -19,13 +19,10 @@ namespace ProjectExplorer {
|
||||
const char STEPS_COUNT_KEY[] = "ProjectExplorer.BuildStepList.StepsCount";
|
||||
const char STEPS_PREFIX[] = "ProjectExplorer.BuildStepList.Step.";
|
||||
|
||||
BuildStepList::BuildStepList(QObject *parent, Utils::Id id)
|
||||
: QObject(parent), m_id(id)
|
||||
BuildStepList::BuildStepList(ProjectConfiguration *config, Utils::Id id)
|
||||
: QObject(config), m_projectConfiguration(config), m_id(id)
|
||||
{
|
||||
QTC_ASSERT(parent, return);
|
||||
QTC_ASSERT(parent->parent(), return);
|
||||
m_target = qobject_cast<Target *>(parent->parent());
|
||||
QTC_ASSERT(m_target, return);
|
||||
QTC_CHECK(config);
|
||||
}
|
||||
|
||||
BuildStepList::~BuildStepList()
|
||||
@@ -39,6 +36,11 @@ void BuildStepList::clear()
|
||||
m_steps.clear();
|
||||
}
|
||||
|
||||
Target *BuildStepList::target() const
|
||||
{
|
||||
return m_projectConfiguration->target();
|
||||
}
|
||||
|
||||
QVariantMap BuildStepList::toMap() const
|
||||
{
|
||||
QVariantMap map;
|
||||
|
@@ -13,6 +13,7 @@
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class BuildStep;
|
||||
class ProjectConfiguration;
|
||||
class Target;
|
||||
|
||||
class PROJECTEXPLORER_EXPORT BuildStepList : public QObject
|
||||
@@ -20,7 +21,7 @@ class PROJECTEXPLORER_EXPORT BuildStepList : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BuildStepList(QObject *parent, Utils::Id id);
|
||||
explicit BuildStepList(ProjectConfiguration *config, Utils::Id id);
|
||||
~BuildStepList() override;
|
||||
|
||||
void clear();
|
||||
@@ -56,7 +57,8 @@ public:
|
||||
void moveStepUp(int position);
|
||||
BuildStep *at(int position) const;
|
||||
|
||||
Target *target() { return m_target; }
|
||||
ProjectConfiguration *projectConfiguration() const { return m_projectConfiguration; }
|
||||
Target *target() const;
|
||||
|
||||
QVariantMap toMap() const;
|
||||
bool fromMap(const QVariantMap &map);
|
||||
@@ -71,7 +73,7 @@ signals:
|
||||
void stepMoved(int from, int to);
|
||||
|
||||
private:
|
||||
Target *m_target;
|
||||
ProjectConfiguration *m_projectConfiguration;
|
||||
Utils::Id m_id;
|
||||
QList<BuildStep *> m_steps;
|
||||
};
|
||||
|
@@ -26,10 +26,9 @@ const char USES_DEPLOYMENT_DATA[] = "ProjectExplorer.DeployConfiguration.CustomD
|
||||
const char DEPLOYMENT_DATA[] = "ProjectExplorer.DeployConfiguration.CustomData";
|
||||
|
||||
DeployConfiguration::DeployConfiguration(Target *target, Id id)
|
||||
: ProjectConfiguration(target, id),
|
||||
m_stepList(this, Constants::BUILDSTEPS_DEPLOY)
|
||||
: ProjectConfiguration(target, target, id)
|
||||
, m_stepList(this, Constants::BUILDSTEPS_DEPLOY)
|
||||
{
|
||||
QTC_CHECK(target && target == this->target());
|
||||
//: Default DeployConfiguration display name
|
||||
setDefaultDisplayName(Tr::tr("Deploy locally"));
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "projectconfiguration.h"
|
||||
|
||||
#include "kitinformation.h"
|
||||
#include "target.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -17,20 +16,15 @@ const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayNam
|
||||
|
||||
// ProjectConfiguration
|
||||
|
||||
ProjectConfiguration::ProjectConfiguration(QObject *parent, Utils::Id id)
|
||||
ProjectConfiguration::ProjectConfiguration(QObject *parent, Target *target, Utils::Id id)
|
||||
: AspectContainer(parent)
|
||||
, m_target(target)
|
||||
, m_id(id)
|
||||
{
|
||||
QTC_CHECK(parent);
|
||||
QTC_CHECK(target);
|
||||
QTC_CHECK(id.isValid());
|
||||
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;
|
||||
|
@@ -26,7 +26,7 @@ class PROJECTEXPLORER_EXPORT ProjectConfiguration : public Utils::AspectContaine
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
explicit ProjectConfiguration(QObject *parent, Utils::Id id);
|
||||
explicit ProjectConfiguration(QObject *parent, Target *target, Utils::Id id);
|
||||
|
||||
public:
|
||||
~ProjectConfiguration() override;
|
||||
|
@@ -160,9 +160,8 @@ void GlobalOrProjectAspect::resetProjectToGlobalSettings()
|
||||
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
|
||||
|
||||
RunConfiguration::RunConfiguration(Target *target, Utils::Id id)
|
||||
: ProjectConfiguration(target, id)
|
||||
: ProjectConfiguration(target, target, id)
|
||||
{
|
||||
QTC_CHECK(target && target == this->target());
|
||||
forceDisplayNameSerialization();
|
||||
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
|
||||
|
||||
|
Reference in New Issue
Block a user