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 <joerg.bornemann@digia.com>
This commit is contained in:
Christian Kandeler
2014-07-10 17:01:54 +02:00
parent 5e8bd53a79
commit 853497fb4b
4 changed files with 56 additions and 66 deletions

View File

@@ -36,8 +36,6 @@
#include <QIcon>
namespace qbs { class Project; }
namespace QbsProjectManager {
namespace Internal {
@@ -165,34 +163,46 @@ class QbsProjectNode : public QbsBaseProjectNode
Q_OBJECT
public:
explicit QbsProjectNode(QbsProject *project);
explicit QbsProjectNode(const QString &path);
~QbsProjectNode();
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
void setProject(const qbs::Project &prj); // This does *not* update the node tree!
void update();
QbsProject *project() const;
virtual QbsProject *project() const;
const qbs::Project qbsProject() const;
const qbs::ProjectData qbsProjectData() const;
bool showInSimpleTree() const;
protected:
void update(const qbs::ProjectData &prjData);
private:
void ctor();
void update(const qbs::ProjectData &prjData);
QbsProductNode *findProductNode(const QString &name);
QbsProjectNode *findProjectNode(const QString &name);
QbsProject *m_project;
qbs::Project m_qbsProject;
static QIcon m_projectIcon;
};
class QbsRootProjectNode : public QbsProjectNode
{
Q_OBJECT
public:
explicit QbsRootProjectNode(QbsProject *project);
using QbsProjectNode::update;
void update();
QbsProject *project() const { return m_project; }
private:
QbsProject * const m_project;
};
} // namespace Internal
} // namespace QbsProjectManager