From a6c85993ba324def14c4e306d940df4d0a47da30 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 26 Jul 2019 09:23:57 +0200 Subject: [PATCH] ProjectExplorer: Propagate build environment changes more directly To check this still works I used a CustomRunConfiguration with a executable name $AAA, the tooltip there tries to expand that (and complains that $AAA is not an executable). By inserting a AAA=/bin/ls in the build environment, the tool tip on the run config exectable path chooser changes appropriately, same for changing the AAA value. The connection seems also needed, dropping it destroys that updating. Change-Id: I28965cbd3ce530a83d98808ca7624a6799cd9800 Reviewed-by: Christian Kandeler --- .../cmakerunconfiguration.cpp | 2 +- .../projectexplorer/buildconfiguration.cpp | 1 + .../projectexplorer/localenvironmentaspect.cpp | 13 +++---------- .../projectexplorer/localenvironmentaspect.h | 2 -- src/plugins/projectexplorer/subscription.cpp | 17 ----------------- src/plugins/projectexplorer/subscription.h | 7 ------- src/plugins/projectexplorer/target.h | 10 +--------- .../qbsprojectmanager/qbsrunconfiguration.cpp | 4 ++-- .../desktopqmakerunconfiguration.cpp | 2 +- 9 files changed, 9 insertions(+), 49 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 50bfeb7b3a1..495f5df4ecc 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -103,7 +103,7 @@ void CMakeRunConfiguration::updateTargetInformation() BuildTargetInfo bti = buildTargetInfo(); aspect()->setExecutable(bti.targetFilePath); aspect()->setDefaultWorkingDirectory(bti.workingDirectory); - aspect()->buildEnvironmentHasChanged(); + aspect()->environmentChanged(); auto terminalAspect = aspect(); terminalAspect->setUseTerminalHint(bti.usesTerminal); diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 48493b27ec9..a4a7d197342 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -101,6 +101,7 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id) connect(this, &BuildConfiguration::environmentChanged, this, [this] { m_buildDirectoryAspect->setEnvironment(environment()); + this->target()->buildEnvironmentChanged(this); }); } diff --git a/src/plugins/projectexplorer/localenvironmentaspect.cpp b/src/plugins/projectexplorer/localenvironmentaspect.cpp index 366b938ed47..48eac494925 100644 --- a/src/plugins/projectexplorer/localenvironmentaspect.cpp +++ b/src/plugins/projectexplorer/localenvironmentaspect.cpp @@ -30,8 +30,6 @@ #include "kit.h" #include "target.h" -#include - using namespace Utils; namespace ProjectExplorer { @@ -56,15 +54,10 @@ LocalEnvironmentAspect::LocalEnvironmentAspect(Target *target) return env; }); - target->subscribeSignal(&BuildConfiguration::environmentChanged, - this, &LocalEnvironmentAspect::buildEnvironmentHasChanged); connect(target, &Target::activeBuildConfigurationChanged, - this, &LocalEnvironmentAspect::buildEnvironmentHasChanged); -} - -void LocalEnvironmentAspect::buildEnvironmentHasChanged() -{ - emit environmentChanged(); + this, &EnvironmentAspect::environmentChanged); + connect(target, &Target::buildEnvironmentChanged, + this, &EnvironmentAspect::environmentChanged); } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/localenvironmentaspect.h b/src/plugins/projectexplorer/localenvironmentaspect.h index 05653899b27..b1e4d5fd557 100644 --- a/src/plugins/projectexplorer/localenvironmentaspect.h +++ b/src/plugins/projectexplorer/localenvironmentaspect.h @@ -35,8 +35,6 @@ class PROJECTEXPLORER_EXPORT LocalEnvironmentAspect : public EnvironmentAspect public: explicit LocalEnvironmentAspect(Target *parent); - - void buildEnvironmentHasChanged(); }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/subscription.cpp b/src/plugins/projectexplorer/subscription.cpp index 3a842351327..6f713c1e97c 100644 --- a/src/plugins/projectexplorer/subscription.cpp +++ b/src/plugins/projectexplorer/subscription.cpp @@ -124,22 +124,5 @@ ProjectSubscription::ProjectSubscription(const Subscription::Connector &s, const ProjectSubscription::~ProjectSubscription() = default; -TargetSubscription::TargetSubscription(const Subscription::Connector &s, const QObject *r, - Target *t) : - Subscription(s, r, t) -{ - QTC_ASSERT(m_subscriber, return); - - subscribe(t); - - // Disconnect on removal of a target, to make it save to remove/add a target: - connect(t->project(), &Project::removedTarget, this, - [t, this](const Target *reportedTarget) { if (t == reportedTarget) { destroy(); } }); - connect(t, &Target::addedProjectConfiguration, this, &TargetSubscription::subscribe); - connect(t, &Target::removedProjectConfiguration, this, &TargetSubscription::unsubscribe); -} - -TargetSubscription::~TargetSubscription() = default; - } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/subscription.h b/src/plugins/projectexplorer/subscription.h index 71aa3596f30..6e2b0128959 100644 --- a/src/plugins/projectexplorer/subscription.h +++ b/src/plugins/projectexplorer/subscription.h @@ -70,12 +70,5 @@ public: ~ProjectSubscription() final; }; -class PROJECTEXPLORER_EXPORT TargetSubscription : public Subscription -{ -public: - TargetSubscription(const Connector &s, const QObject *receiver, Target *t); - ~TargetSubscription() final; -}; - } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/target.h b/src/plugins/projectexplorer/target.h index f5c7fcabd19..52f84e908b9 100644 --- a/src/plugins/projectexplorer/target.h +++ b/src/plugins/projectexplorer/target.h @@ -119,15 +119,6 @@ public: QVariant additionalData(Core::Id id) const; MakeInstallCommand makeInstallCommand(const QString &installRoot) const; - template - void subscribeSignal(void (S::*sig)(), R*recv, T (R::*sl)()) { - new Internal::TargetSubscription([sig, recv, sl, this](ProjectConfiguration *pc) { - if (S* sender = qobject_cast(pc)) - return connect(sender, sig, recv, sl); - return QMetaObject::Connection(); - }, recv, this); - } - signals: void targetEnabled(bool); void iconChanged(); @@ -150,6 +141,7 @@ signals: void removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc); void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc); void activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration *); + void buildEnvironmentChanged(ProjectExplorer::BuildConfiguration *bc); void removedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc); void addedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc); diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp index d4960b3524e..258ccedbfa6 100644 --- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp @@ -84,8 +84,8 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id) }); } - connect(project(), &Project::parsingFinished, this, - [envAspect]() { envAspect->buildEnvironmentHasChanged(); }); + connect(project(), &Project::parsingFinished, + envAspect, &EnvironmentAspect::environmentChanged); connect(target, &Target::deploymentDataChanged, this, &QbsRunConfiguration::updateTargetInformation); diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp index 8cf53db49ba..c055e9bc030 100644 --- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp @@ -97,7 +97,7 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target, Core: void DesktopQmakeRunConfiguration::updateTargetInformation() { setDefaultDisplayName(defaultDisplayName()); - aspect()->buildEnvironmentHasChanged(); + aspect()->environmentChanged(); BuildTargetInfo bti = buildTargetInfo();