forked from qt-creator/qt-creator
ProjectExplorer: Remove target/BC listeners from ExtraCompiler
When target or build configuration change, the target files that ExtraCompiler checks to see if a rebuild is necessary will be outdated. The project managers recognize that and reinitialize the ExtraCompilers in that case. Thus, we don't need to listen for those changes in ExtraCompiler. This has the added benefit of reducing the number of transparent rebuilds triggered by ExtraCompiler. Change-Id: If8b55f0f5343b221c039d4bd4a8f0c3ab412cc94 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -80,9 +80,6 @@ ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FileName &sour
|
||||
d->contents.insert(target, QByteArray());
|
||||
d->timer.setSingleShot(true);
|
||||
|
||||
connect(d->project, &Project::activeTargetChanged, this, &ExtraCompiler::onActiveTargetChanged);
|
||||
onActiveTargetChanged();
|
||||
|
||||
connect(&d->timer, &QTimer::timeout, this, [this](){
|
||||
if (d->dirty && d->lastEditor) {
|
||||
d->dirty = false;
|
||||
@@ -254,41 +251,6 @@ void ExtraCompiler::onEditorAboutToClose(Core::IEditor *editor)
|
||||
d->lastEditor = nullptr;
|
||||
}
|
||||
|
||||
void ExtraCompiler::onActiveTargetChanged()
|
||||
{
|
||||
disconnect(d->activeBuildConfigConnection);
|
||||
if (Target *target = d->project->activeTarget()) {
|
||||
d->activeBuildConfigConnection = connect(
|
||||
target, &Target::activeBuildConfigurationChanged,
|
||||
this, &ExtraCompiler::onActiveBuildConfigurationChanged);
|
||||
onActiveBuildConfigurationChanged();
|
||||
} else {
|
||||
disconnect(d->activeEnvironmentConnection);
|
||||
setDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void ExtraCompiler::onActiveBuildConfigurationChanged()
|
||||
{
|
||||
disconnect(d->activeEnvironmentConnection);
|
||||
Target *target = d->project->activeTarget();
|
||||
QTC_ASSERT(target, return);
|
||||
if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
|
||||
d->activeEnvironmentConnection = connect(
|
||||
bc, &BuildConfiguration::environmentChanged,
|
||||
this, &ExtraCompiler::setDirty);
|
||||
} else {
|
||||
d->activeEnvironmentConnection = connect(KitManager::instance(), &KitManager::kitUpdated,
|
||||
this, [this](Kit *kit) {
|
||||
Target *target = d->project->activeTarget();
|
||||
QTC_ASSERT(target, return);
|
||||
if (kit == target->kit())
|
||||
setDirty();
|
||||
});
|
||||
}
|
||||
setDirty();
|
||||
}
|
||||
|
||||
Utils::Environment ExtraCompiler::buildEnvironment() const
|
||||
{
|
||||
if (Target *target = project()->activeTarget()) {
|
||||
|
@@ -84,8 +84,6 @@ private:
|
||||
void onTargetsBuilt(Project *project);
|
||||
void onEditorChanged(Core::IEditor *editor);
|
||||
void onEditorAboutToClose(Core::IEditor *editor);
|
||||
void onActiveTargetChanged();
|
||||
void onActiveBuildConfigurationChanged();
|
||||
void setDirty();
|
||||
// This method may not block!
|
||||
virtual void run(const QByteArray &sourceContent) = 0;
|
||||
|
Reference in New Issue
Block a user