From 853497fb4b4c140cd05f529aac23a3b0fadbc02c Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 10 Jul 2014 17:01:54 +0200 Subject: QbsProjectManager: Sanitize QbsProjectNode. The current code keeps an instance of QbsProject and of qbs::Project in every project node, with them being null/invalid everywhere except for the top-level node. Instead, introduce a dedicated class for the root node and hold a QbsProject only there. The qbs::Project is held in QbsProject now. As a nice side effect, this also fixes QBS-644, presumably because the dubious-looking use of projectNode() has been removed. Task-number: QBS-644 Change-Id: I5d36806745b9d67879db6f48aa56bc97868e4f17 Reviewed-by: Joerg Bornemann --- src/plugins/qbsprojectmanager/qbsproject.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src/plugins/qbsprojectmanager/qbsproject.cpp') diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index c0d69a8c1b..18861fd4c5 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -120,7 +120,7 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) : updateDocuments(QSet() << fileName); // NOTE: QbsProjectNode does not use this as a parent! - m_rootProjectNode = new QbsProjectNode(this); // needs documents to be initialized! + m_rootProjectNode = new QbsRootProjectNode(this); // needs documents to be initialized! } QbsProject::~QbsProject() @@ -255,16 +255,14 @@ Utils::FileName QbsProject::defaultBuildDirectory(const QString &projectFilePath qbs::Project QbsProject::qbsProject() const { - if (!m_rootProjectNode) - return qbs::Project(); - return m_rootProjectNode->qbsProject(); + return m_qbsProject; } const qbs::ProjectData QbsProject::qbsProjectData() const { - if (!m_rootProjectNode) - return qbs::ProjectData(); - return m_rootProjectNode->qbsProjectData(); + if (m_qbsProject.isValid()) + return m_qbsProject.projectData(); + return qbs::ProjectData(); } bool QbsProject::needsSpecialDeployment() const @@ -276,12 +274,14 @@ void QbsProject::handleQbsParsingDone(bool success) { QTC_ASSERT(m_qbsProjectParser, return); - qbs::Project project; - if (success) - project = m_qbsProjectParser->qbsProject(); - generateErrors(m_qbsProjectParser->error()); + if (success) { + m_qbsProject = m_qbsProjectParser->qbsProject(); + QTC_CHECK(m_qbsProject.isValid()); + readQbsData(); + } + m_qbsProjectParser->deleteLater(); m_qbsProjectParser = 0; @@ -291,11 +291,6 @@ void QbsProject::handleQbsParsingDone(bool success) m_qbsUpdateFutureInterface = 0; } - if (project.isValid()) - m_rootProjectNode->setProject(project); - - readQbsData(); - emit projectParsingDone(success); } -- cgit v1.2.1