Commit 2b3d4685 authored by Christian Kandeler's avatar Christian Kandeler Committed by Christian Kandeler

QbsProjectManager: Have one qbs::Project per target

The class qbs::Project corresponds to a Qt Creator target, not to a Qt
Creator project. It represents a project set up for a particular
configuration.

Task-number: QTCREATORBUG-16545
Change-Id: I9e4fa6a4bf763e49335f294609d7465545df4559
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent 9ac9211d
......@@ -119,6 +119,7 @@ QbsProject::QbsProject(QbsManager *manager, const QString &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);
connect(&m_parsingDelay, &QTimer::timeout, this, &QbsProject::startParsing);
......@@ -469,6 +470,7 @@ void QbsProject::handleQbsParsingDone(bool success)
generateErrors(m_qbsProjectParser->error());
m_qbsProject = m_qbsProjectParser->qbsProject();
m_qbsProjects.insert(activeTarget(), m_qbsProject);
bool dataChanged = false;
if (success) {
QTC_ASSERT(m_qbsProject.isValid(), return);
......@@ -529,15 +531,26 @@ void QbsProject::handleRuleExecutionDone()
void QbsProject::targetWasAdded(Target *t)
{
m_qbsProjects.insert(t, qbs::Project());
connect(t, &Target::activeBuildConfigurationChanged, this, &QbsProject::delayParsing);
connect(t, &Target::buildDirectoryChanged, this, &QbsProject::delayParsing);
}
void QbsProject::targetWasRemoved(Target *t)
{
m_qbsProjects.remove(t);
}
void QbsProject::changeActiveTarget(Target *t)
{
BuildConfiguration *bc = 0;
if (t && t->kit())
bc = t->activeBuildConfiguration();
if (t) {
m_qbsProject = m_qbsProjects.value(t);
if (m_qbsProject.isValid())
m_projectData = m_qbsProject.projectData();
if (t->kit())
bc = t->activeBuildConfiguration();
}
buildConfigurationChanged(bc);
}
......
......@@ -41,6 +41,7 @@
#include <qbs.h>
#include <QFuture>
#include <QHash>
#include <QTimer>
namespace Core { class IDocument; }
......@@ -118,6 +119,7 @@ private:
void handleQbsParsingDone(bool success);
void targetWasAdded(ProjectExplorer::Target *t);
void targetWasRemoved(ProjectExplorer::Target *t);
void changeActiveTarget(ProjectExplorer::Target *t);
void buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc);
void startParsing();
......@@ -145,6 +147,7 @@ private:
const qbs::GroupData &oldGroup);
const QString m_projectName;
QHash<ProjectExplorer::Target *, qbs::Project> m_qbsProjects;
qbs::Project m_qbsProject;
qbs::ProjectData m_projectData;
QSet<Core::IDocument *> m_qbsDocuments;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment