ProjectExplorer: Add subscribeSignal method to targets and projects

Add a subscribeSignal method to targets and projects that will make
sure all signals of all project configurations added during the lifetime
of the project/target will get connected (if the type matches).

Use this to connect to some signal in all BuildConfigurations of
a project and get rid of code that keeps connecting to the current
build configuration.

Use Project::buildEnvironmentChanged as an example and convert its
usages.

Change-Id: I689bcebac4b191bf3f8a18765bf18eaac371c5fe
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2017-07-29 23:34:56 +02:00
parent 34456aa906
commit e52ebbf217
17 changed files with 291 additions and 46 deletions

View File

@@ -140,7 +140,15 @@ QbsProject::QbsProject(const FileName &fileName) :
connect(this, &Project::activeTargetChanged, this, &QbsProject::changeActiveTarget);
connect(this, &Project::addedTarget, this, &QbsProject::targetWasAdded);
connect(this, &Project::removedTarget, this, &QbsProject::targetWasRemoved);
connect(this, &Project::environmentChanged, this, &QbsProject::delayParsing);
subscribeSignal(&BuildConfiguration::environmentChanged, this, [this]() {
if (static_cast<BuildConfiguration *>(sender())->isActive())
startParsing();
});
connect(this, &Project::activeProjectConfigurationChanged,
this, [this](ProjectConfiguration *pc) {
if (pc->isActive())
startParsing();
});
connect(&m_parsingDelay, &QTimer::timeout, this, &QbsProject::startParsing);