From 190aa94be7f5e146bef44862b974d733755cec85 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 14 Aug 2017 18:30:29 +0200 Subject: Change source identifier type in ProString The strings remember in which file they were created/assigned. However, this used a non-counting reference to a ProFile, which could become dangling. If a subsequent ProFile re-used the exact same address, a string's source would be mis-identified, which would be fatal in conjunction with discard_from(). Since we actually need only a unique id for comparison, let's use an integer for that. Task-number: QTBUG-62434 Started-by: Simon Hausmann Change-Id: I395153afaf7c835d0119690ee7f4b915e6f90d4a Reviewed-by: Simon Hausmann --- qmake/library/proitems.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'qmake/library/proitems.h') diff --git a/qmake/library/proitems.h b/qmake/library/proitems.h index c81e205699..6ce8c98789 100644 --- a/qmake/library/proitems.h +++ b/qmake/library/proitems.h @@ -73,8 +73,8 @@ public: void setValue(const QString &str); void clear() { m_string.clear(); m_length = 0; } ProString &setSource(const ProString &other) { m_file = other.m_file; return *this; } - ProString &setSource(const ProFile *pro) { m_file = pro; return *this; } - const ProFile *sourceFile() const { return m_file; } + ProString &setSource(int id) { m_file = id; return *this; } + int sourceFile() const { return m_file; } ProString &prepend(const ProString &other); ProString &append(const ProString &other, bool *pending = 0); @@ -163,7 +163,7 @@ private: QString m_string; int m_offset, m_length; - const ProFile *m_file; + int m_file; mutable uint m_hash; QChar *prepareExtend(int extraLen, int thisTarget, int extraTarget); uint updatedHash() const; @@ -340,9 +340,10 @@ enum ProToken { class QMAKE_EXPORT ProFile { public: - explicit ProFile(const QString &fileName); + ProFile(int id, const QString &fileName); ~ProFile(); + int id() const { return m_id; } QString fileName() const { return m_fileName; } QString directoryName() const { return m_directoryName; } const QString &items() const { return m_proitems; } @@ -367,6 +368,7 @@ private: QString m_proitems; QString m_fileName; QString m_directoryName; + int m_id; bool m_ok; bool m_hostBuild; }; -- cgit v1.2.3