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) : ...@@ -119,6 +119,7 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
connect(this, &Project::activeTargetChanged, this, &QbsProject::changeActiveTarget); connect(this, &Project::activeTargetChanged, this, &QbsProject::changeActiveTarget);
connect(this, &Project::addedTarget, this, &QbsProject::targetWasAdded); connect(this, &Project::addedTarget, this, &QbsProject::targetWasAdded);
connect(this, &Project::removedTarget, this, &QbsProject::targetWasRemoved);
connect(this, &Project::environmentChanged, this, &QbsProject::delayParsing); connect(this, &Project::environmentChanged, this, &QbsProject::delayParsing);
connect(&m_parsingDelay, &QTimer::timeout, this, &QbsProject::startParsing); connect(&m_parsingDelay, &QTimer::timeout, this, &QbsProject::startParsing);
...@@ -469,6 +470,7 @@ void QbsProject::handleQbsParsingDone(bool success) ...@@ -469,6 +470,7 @@ void QbsProject::handleQbsParsingDone(bool success)
generateErrors(m_qbsProjectParser->error()); generateErrors(m_qbsProjectParser->error());
m_qbsProject = m_qbsProjectParser->qbsProject(); m_qbsProject = m_qbsProjectParser->qbsProject();
m_qbsProjects.insert(activeTarget(), m_qbsProject);
bool dataChanged = false; bool dataChanged = false;
if (success) { if (success) {
QTC_ASSERT(m_qbsProject.isValid(), return); QTC_ASSERT(m_qbsProject.isValid(), return);
...@@ -529,15 +531,26 @@ void QbsProject::handleRuleExecutionDone() ...@@ -529,15 +531,26 @@ void QbsProject::handleRuleExecutionDone()
void QbsProject::targetWasAdded(Target *t) void QbsProject::targetWasAdded(Target *t)
{ {
m_qbsProjects.insert(t, qbs::Project());
connect(t, &Target::activeBuildConfigurationChanged, this, &QbsProject::delayParsing); connect(t, &Target::activeBuildConfigurationChanged, this, &QbsProject::delayParsing);
connect(t, &Target::buildDirectoryChanged, this, &QbsProject::delayParsing); connect(t, &Target::buildDirectoryChanged, this, &QbsProject::delayParsing);
} }
void QbsProject::targetWasRemoved(Target *t)
{
m_qbsProjects.remove(t);
}
void QbsProject::changeActiveTarget(Target *t) void QbsProject::changeActiveTarget(Target *t)
{ {
BuildConfiguration *bc = 0; BuildConfiguration *bc = 0;
if (t && t->kit()) if (t) {
bc = t->activeBuildConfiguration(); m_qbsProject = m_qbsProjects.value(t);
if (m_qbsProject.isValid())
m_projectData = m_qbsProject.projectData();
if (t->kit())
bc = t->activeBuildConfiguration();
}
buildConfigurationChanged(bc); buildConfigurationChanged(bc);
} }
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <qbs.h> #include <qbs.h>
#include <QFuture> #include <QFuture>
#include <QHash>
#include <QTimer> #include <QTimer>
namespace Core { class IDocument; } namespace Core { class IDocument; }
...@@ -118,6 +119,7 @@ private: ...@@ -118,6 +119,7 @@ private:
void handleQbsParsingDone(bool success); void handleQbsParsingDone(bool success);
void targetWasAdded(ProjectExplorer::Target *t); void targetWasAdded(ProjectExplorer::Target *t);
void targetWasRemoved(ProjectExplorer::Target *t);
void changeActiveTarget(ProjectExplorer::Target *t); void changeActiveTarget(ProjectExplorer::Target *t);
void buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc); void buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc);
void startParsing(); void startParsing();
...@@ -145,6 +147,7 @@ private: ...@@ -145,6 +147,7 @@ private:
const qbs::GroupData &oldGroup); const qbs::GroupData &oldGroup);
const QString m_projectName; const QString m_projectName;
QHash<ProjectExplorer::Target *, qbs::Project> m_qbsProjects;
qbs::Project m_qbsProject; qbs::Project m_qbsProject;
qbs::ProjectData m_projectData; qbs::ProjectData m_projectData;
QSet<Core::IDocument *> m_qbsDocuments; 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