qmake: QmakeParserPriFileNode: Use unique_ptr

Use unique_ptr to hold the QmakePriFileDocument. That makes
it clearer that QmakePriFileNode owns it.

Change-Id: Ia31778ad2a9d33a13cf818d3bcad0485ebfa2043
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
Tobias Hunger
2017-02-09 15:09:25 +01:00
parent e376424b33
commit 671e1626da
2 changed files with 9 additions and 8 deletions

View File

@@ -460,8 +460,8 @@ QmakeParserPriFileNode::QmakeParserPriFileNode(QmakeProject *project,
m_projectDir(filePath.toFileInfo().absolutePath()) m_projectDir(filePath.toFileInfo().absolutePath())
{ {
Q_ASSERT(project); Q_ASSERT(project);
m_priFileDocument = new QmakePriFileDocument(this); m_priFileDocument = std::make_unique<QmakePriFileDocument>(this);
Core::DocumentManager::addDocument(m_priFileDocument); Core::DocumentManager::addDocument(m_priFileDocument.get());
setDisplayName(filePath.toFileInfo().completeBaseName()); setDisplayName(filePath.toFileInfo().completeBaseName());
setIcon(qmakeParserNodeStaticData()->projectIcon); setIcon(qmakeParserNodeStaticData()->projectIcon);
@@ -470,7 +470,6 @@ QmakeParserPriFileNode::QmakeParserPriFileNode(QmakeProject *project,
QmakeParserPriFileNode::~QmakeParserPriFileNode() QmakeParserPriFileNode::~QmakeParserPriFileNode()
{ {
watchFolders(QSet<QString>()); watchFolders(QSet<QString>());
delete m_priFileDocument;
} }
void QmakeParserPriFileNode::scheduleUpdate() void QmakeParserPriFileNode::scheduleUpdate()

View File

@@ -38,6 +38,8 @@
#include <QMap> #include <QMap>
#include <QFutureWatcher> #include <QFutureWatcher>
#include <memory>
namespace Utils { class FileName; } namespace Utils { class FileName; }
namespace QtSupport { class ProFileReader; } namespace QtSupport { class ProFileReader; }
@@ -99,7 +101,6 @@ enum class Variable {
uint qHash(Variable key, uint seed = 0); uint qHash(Variable key, uint seed = 0);
namespace Internal { namespace Internal {
class QmakePriFileDocument;
struct InternalParserNode; struct InternalParserNode;
class QmakeEvalInput; class QmakeEvalInput;
@@ -152,6 +153,8 @@ public:
static QSet<Utils::FileName> recursiveEnumerate(const QString &folder); static QSet<Utils::FileName> recursiveEnumerate(const QString &folder);
void scheduleUpdate();
protected: protected:
void setIncludedInExactParse(bool b); void setIncludedInExactParse(bool b);
static QStringList varNames(ProjectExplorer::FileType type, QtSupport::ProFileReader *readerExact); static QStringList varNames(ProjectExplorer::FileType type, QtSupport::ProFileReader *readerExact);
@@ -176,9 +179,8 @@ protected:
ChangeType change, ChangeType change,
Change mode = Change::Save); Change mode = Change::Save);
private:
void scheduleUpdate();
private:
bool prepareForChange(); bool prepareForChange();
static bool ensureWriteableProFile(const QString &file); static bool ensureWriteableProFile(const QString &file);
static QPair<ProFile *, QStringList> readProFile(const QString &file); static QPair<ProFile *, QStringList> readProFile(const QString &file);
@@ -205,7 +207,7 @@ private:
Utils::FileName m_projectFilePath; Utils::FileName m_projectFilePath;
QString m_projectDir; QString m_projectDir;
Internal::QmakePriFileDocument *m_priFileDocument; std::unique_ptr<Core::IDocument> m_priFileDocument;
// Memory is cheap... // Memory is cheap...
QMap<ProjectExplorer::FileType, QSet<Utils::FileName>> m_files; QMap<ProjectExplorer::FileType, QSet<Utils::FileName>> m_files;
@@ -215,7 +217,6 @@ private:
// managed by QmakeProFileNode // managed by QmakeProFileNode
friend class QmakeProjectManager::QmakeParserProFileNode; friend class QmakeProjectManager::QmakeParserProFileNode;
friend class Internal::QmakePriFileDocument; // for scheduling updates on modified
// internal temporary subtree representation // internal temporary subtree representation
friend struct Internal::InternalParserNode; friend struct Internal::InternalParserNode;
}; };
@@ -298,6 +299,7 @@ public:
QByteArray cxxDefines() const; QByteArray cxxDefines() const;
enum AsyncUpdateDelay { ParseNow, ParseLater }; enum AsyncUpdateDelay { ParseNow, ParseLater };
using QmakeParserPriFileNode::scheduleUpdate;
void scheduleUpdate(AsyncUpdateDelay delay); void scheduleUpdate(AsyncUpdateDelay delay);
bool validParse() const; bool validParse() const;