forked from qt-creator/qt-creator
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 <christian.kandeler@qt.io>
This commit is contained in:
@@ -103,7 +103,7 @@ void CMakeRunConfiguration::updateTargetInformation()
|
|||||||
BuildTargetInfo bti = buildTargetInfo();
|
BuildTargetInfo bti = buildTargetInfo();
|
||||||
aspect<ExecutableAspect>()->setExecutable(bti.targetFilePath);
|
aspect<ExecutableAspect>()->setExecutable(bti.targetFilePath);
|
||||||
aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(bti.workingDirectory);
|
aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(bti.workingDirectory);
|
||||||
aspect<LocalEnvironmentAspect>()->buildEnvironmentHasChanged();
|
aspect<LocalEnvironmentAspect>()->environmentChanged();
|
||||||
|
|
||||||
auto terminalAspect = aspect<TerminalAspect>();
|
auto terminalAspect = aspect<TerminalAspect>();
|
||||||
terminalAspect->setUseTerminalHint(bti.usesTerminal);
|
terminalAspect->setUseTerminalHint(bti.usesTerminal);
|
||||||
|
@@ -101,6 +101,7 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id)
|
|||||||
|
|
||||||
connect(this, &BuildConfiguration::environmentChanged, this, [this] {
|
connect(this, &BuildConfiguration::environmentChanged, this, [this] {
|
||||||
m_buildDirectoryAspect->setEnvironment(environment());
|
m_buildDirectoryAspect->setEnvironment(environment());
|
||||||
|
this->target()->buildEnvironmentChanged(this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,8 +30,6 @@
|
|||||||
#include "kit.h"
|
#include "kit.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -56,15 +54,10 @@ LocalEnvironmentAspect::LocalEnvironmentAspect(Target *target)
|
|||||||
return env;
|
return env;
|
||||||
});
|
});
|
||||||
|
|
||||||
target->subscribeSignal(&BuildConfiguration::environmentChanged,
|
|
||||||
this, &LocalEnvironmentAspect::buildEnvironmentHasChanged);
|
|
||||||
connect(target, &Target::activeBuildConfigurationChanged,
|
connect(target, &Target::activeBuildConfigurationChanged,
|
||||||
this, &LocalEnvironmentAspect::buildEnvironmentHasChanged);
|
this, &EnvironmentAspect::environmentChanged);
|
||||||
}
|
connect(target, &Target::buildEnvironmentChanged,
|
||||||
|
this, &EnvironmentAspect::environmentChanged);
|
||||||
void LocalEnvironmentAspect::buildEnvironmentHasChanged()
|
|
||||||
{
|
|
||||||
emit environmentChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -35,8 +35,6 @@ class PROJECTEXPLORER_EXPORT LocalEnvironmentAspect : public EnvironmentAspect
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LocalEnvironmentAspect(Target *parent);
|
explicit LocalEnvironmentAspect(Target *parent);
|
||||||
|
|
||||||
void buildEnvironmentHasChanged();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -124,22 +124,5 @@ ProjectSubscription::ProjectSubscription(const Subscription::Connector &s, const
|
|||||||
|
|
||||||
ProjectSubscription::~ProjectSubscription() = default;
|
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 Internal
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -70,12 +70,5 @@ public:
|
|||||||
~ProjectSubscription() final;
|
~ProjectSubscription() final;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT TargetSubscription : public Subscription
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TargetSubscription(const Connector &s, const QObject *receiver, Target *t);
|
|
||||||
~TargetSubscription() final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -119,15 +119,6 @@ public:
|
|||||||
QVariant additionalData(Core::Id id) const;
|
QVariant additionalData(Core::Id id) const;
|
||||||
MakeInstallCommand makeInstallCommand(const QString &installRoot) const;
|
MakeInstallCommand makeInstallCommand(const QString &installRoot) const;
|
||||||
|
|
||||||
template<typename S, typename R, typename T>
|
|
||||||
void subscribeSignal(void (S::*sig)(), R*recv, T (R::*sl)()) {
|
|
||||||
new Internal::TargetSubscription([sig, recv, sl, this](ProjectConfiguration *pc) {
|
|
||||||
if (S* sender = qobject_cast<S*>(pc))
|
|
||||||
return connect(sender, sig, recv, sl);
|
|
||||||
return QMetaObject::Connection();
|
|
||||||
}, recv, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void targetEnabled(bool);
|
void targetEnabled(bool);
|
||||||
void iconChanged();
|
void iconChanged();
|
||||||
@@ -150,6 +141,7 @@ signals:
|
|||||||
void removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
void removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
||||||
void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
||||||
void activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration *);
|
void activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration *);
|
||||||
|
void buildEnvironmentChanged(ProjectExplorer::BuildConfiguration *bc);
|
||||||
|
|
||||||
void removedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
|
void removedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
|
||||||
void addedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
|
void addedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
|
||||||
|
@@ -84,8 +84,8 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(project(), &Project::parsingFinished, this,
|
connect(project(), &Project::parsingFinished,
|
||||||
[envAspect]() { envAspect->buildEnvironmentHasChanged(); });
|
envAspect, &EnvironmentAspect::environmentChanged);
|
||||||
|
|
||||||
connect(target, &Target::deploymentDataChanged,
|
connect(target, &Target::deploymentDataChanged,
|
||||||
this, &QbsRunConfiguration::updateTargetInformation);
|
this, &QbsRunConfiguration::updateTargetInformation);
|
||||||
|
@@ -97,7 +97,7 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target, Core:
|
|||||||
void DesktopQmakeRunConfiguration::updateTargetInformation()
|
void DesktopQmakeRunConfiguration::updateTargetInformation()
|
||||||
{
|
{
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
setDefaultDisplayName(defaultDisplayName());
|
||||||
aspect<LocalEnvironmentAspect>()->buildEnvironmentHasChanged();
|
aspect<EnvironmentAspect>()->environmentChanged();
|
||||||
|
|
||||||
BuildTargetInfo bti = buildTargetInfo();
|
BuildTargetInfo bti = buildTargetInfo();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user