Refresh generic project when build config changes

Now that the generic manager can use data from the target or the build
configuration for expanding entries in its projects files it is
important that it reacts to changes of these entities. A change in the
build configuration can change the include directories or even compile
flags stored in the project configuration and hence the C++ code model
needs to be updated to reflect such changes.

The code is based on the qmake's project manager which has similar
functionality as far as I understood. The only difference is that the
generic manager won't attempt to refresh its state in the background (as
it simply can't do that right now) so the ui will be blocked for a bit.

Change-Id: I0a85e1ff0deeb876a7934b9a193a5d0f020047c7
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Andreas Pakulat
2016-12-20 22:17:20 +01:00
parent c79d290ca2
commit 69159ab483
2 changed files with 34 additions and 0 deletions

View File

@@ -366,6 +366,28 @@ void GenericProject::refreshCppCodeModel()
m_codeModelFuture = modelManager->updateProjectInfo(pInfo);
}
void GenericProject::activeTargetWasChanged()
{
if (m_activeTarget) {
disconnect(m_activeTarget, &Target::activeBuildConfigurationChanged,
this, &GenericProject::activeBuildConfigurationWasChanged);
}
m_activeTarget = activeTarget();
if (!m_activeTarget)
return;
connect(m_activeTarget, &Target::activeBuildConfigurationChanged,
this, &GenericProject::activeBuildConfigurationWasChanged);
refresh(Everything);
}
void GenericProject::activeBuildConfigurationWasChanged()
{
refresh(Everything);
}
QStringList GenericProject::projectIncludePaths() const
{
return m_projectIncludePaths;
@@ -422,6 +444,14 @@ Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString *
t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
}
m_activeTarget = activeTarget();
if (m_activeTarget) {
connect(m_activeTarget, &Target::activeBuildConfigurationChanged,
this, &GenericProject::activeBuildConfigurationWasChanged);
}
connect(this, &Project::activeTargetChanged,
this, &GenericProject::activeTargetWasChanged);
refresh(Everything);
return RestoreResult::Ok;
}