ProjectExplorer: Remove Target::_constructor_tag

Change-Id: Ic9a25ec271af4bd4a9a2d916ab13833c883a9963
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2025-03-13 17:35:00 +01:00
parent 78b468b0cc
commit cdca663ede
3 changed files with 14 additions and 11 deletions

View File

@@ -300,7 +300,7 @@ Target *Project::addTargetForKit(Kit *kit)
if (!kit || target(kit)) if (!kit || target(kit))
return nullptr; return nullptr;
auto t = std::make_unique<Target>(this, kit, Target::_constructor_tag{}); auto t = Target::create(this, kit);
Target *pointer = t.get(); Target *pointer = t.get();
t->updateDefaultBuildConfigurations(); t->updateDefaultBuildConfigurations();
@@ -534,7 +534,7 @@ Target *Project::createKitAndTargetFromStore(const Utils::Store &store)
kit->setup(); kit->setup();
}); });
QTC_ASSERT(k, return nullptr); QTC_ASSERT(k, return nullptr);
auto t = std::make_unique<Target>(this, k, Target::_constructor_tag{}); auto t = Target::create(this, k);
if (!t->fromMap(store)) if (!t->fromMap(store))
return nullptr; return nullptr;
@@ -636,7 +636,7 @@ bool Project::copySteps(const Utils::Store &store, Kit *targetKit)
{ {
Target *t = target(targetKit->id()); Target *t = target(targetKit->id());
if (!t) { if (!t) {
auto t = std::make_unique<Target>(this, targetKit, Target::_constructor_tag{}); auto t = Target::create(this, targetKit);
if (!t->fromMap(store)) if (!t->fromMap(store))
return false; return false;
@@ -905,7 +905,7 @@ void Project::createTargetFromMap(const Store &map, int index)
return; return;
} }
auto t = std::make_unique<Target>(this, k, Target::_constructor_tag{}); auto t = Target::create(this, k);
if (!t->fromMap(targetMap)) if (!t->fromMap(targetMap))
return; return;
@@ -1110,7 +1110,7 @@ BuildConfiguration *Project::setup(const BuildInfo &info)
Target *t = target(k); Target *t = target(k);
std::unique_ptr<Target> newTarget; std::unique_ptr<Target> newTarget;
if (!t) { if (!t) {
newTarget = std::make_unique<Target>(this, k, Target::_constructor_tag{}); newTarget = Target::create(this, k);
t = newTarget.get(); t = newTarget.get();
} }

View File

@@ -70,7 +70,12 @@ public:
}; };
Target::Target(Project *project, Kit *k, _constructor_tag) : std::unique_ptr<Target> Target::create(Project *parent, Kit *k)
{
return std::unique_ptr<Target>(new Target(parent, k));
}
Target::Target(Project *project, Kit *k) :
QObject(project), QObject(project),
d(std::make_unique<TargetPrivate>(k)) d(std::make_unique<TargetPrivate>(k))
{ {

View File

@@ -36,11 +36,6 @@ class PROJECTEXPLORER_EXPORT Target : public QObject
Q_OBJECT Q_OBJECT
public: public:
struct _constructor_tag
{
explicit _constructor_tag() = default;
};
Target(Project *parent, Kit *k, _constructor_tag);
~Target() override; ~Target() override;
void markAsShuttingDown(); void markAsShuttingDown();
@@ -100,6 +95,9 @@ signals:
void activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration *dc); void activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration *dc);
private: private:
static std::unique_ptr<Target> create(Project *parent, Kit *k);
Target(Project *parent, Kit *k);
bool fromMap(const Utils::Store &map); bool fromMap(const Utils::Store &map);
bool addConfigurationsFromMap(const Utils::Store &map, bool setActiveConfigurations); bool addConfigurationsFromMap(const Utils::Store &map, bool setActiveConfigurations);