Mercurial > hg > svcore
diff base/XmlExportable.h @ 1677:f97d64b8674f single-point
Make XmlExportables store their export IDs and always obtain a new one, avoiding reuse when an object is allocated at the same heap location as a previous one. This makes the ID system stable enough to be used in the export tests.
author | Chris Cannam |
---|---|
date | Thu, 28 Mar 2019 11:55:02 +0000 |
parents | ad5f892c0c4d |
children | 4abc0f08adf9 |
line wrap: on
line diff
--- a/base/XmlExportable.h Thu Mar 28 10:39:24 2019 +0000 +++ b/base/XmlExportable.h Thu Mar 28 11:55:02 2019 +0000 @@ -25,9 +25,17 @@ class XmlExportable { public: + XmlExportable() : m_exportId(-1) { } virtual ~XmlExportable() { } /** + * Return the numerical export identifier for this object. It's + * allocated the first time this is called, so objects on which + * this is never called do not get allocated one. + */ + int getExportId() const; + + /** * Stream this exportable object out to XML on a text stream. */ virtual void toXml(QTextStream &stream, @@ -46,7 +54,8 @@ static QString encodeColour(int r, int g, int b); - static int getObjectExportId(const void *); // thread-safe +private: + mutable int m_exportId; }; #endif