comparison data/model/PathModel.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 6804af71b7be
children 0d89abd631ac
comparison
equal deleted inserted replaced
1676:3b51df7695a4 1677:f97d64b8674f
165 * XmlExportable methods. 165 * XmlExportable methods.
166 */ 166 */
167 void toXml(QTextStream &out, 167 void toXml(QTextStream &out,
168 QString indent = "", 168 QString indent = "",
169 QString extraAttributes = "") const override { 169 QString extraAttributes = "") const override {
170
171 // Our dataset doesn't have its own export ID, we just use
172 // ours. Actually any model could do that, since datasets
173 // aren't in the same id-space as models when re-read
170 174
171 Model::toXml 175 Model::toXml
172 (out, 176 (out,
173 indent, 177 indent,
174 QString("type=\"sparse\" dimensions=\"2\" resolution=\"%1\" " 178 QString("type=\"sparse\" dimensions=\"2\" resolution=\"%1\" "
175 "notifyOnAdd=\"%2\" dataset=\"%3\" subtype=\"path\" %4") 179 "notifyOnAdd=\"%2\" dataset=\"%3\" subtype=\"path\" %4")
176 .arg(m_resolution) 180 .arg(m_resolution)
177 .arg("true") // always true after model reaches 100% - 181 .arg("true") // always true after model reaches 100% -
178 // subsequent points are always notified 182 // subsequent points are always notified
179 .arg(getObjectExportId(&m_points)) 183 .arg(getExportId())
180 .arg(extraAttributes)); 184 .arg(extraAttributes));
181 185
182 out << indent << QString("<dataset id=\"%1\" dimensions=\"2\">\n") 186 out << indent << QString("<dataset id=\"%1\" dimensions=\"2\">\n")
183 .arg(getObjectExportId(&m_points)); 187 .arg(getExportId());
184 188
185 for (PathPoint p: m_points) { 189 for (PathPoint p: m_points) {
186 p.toXml(out, indent + " ", ""); 190 p.toXml(out, indent + " ", "");
187 } 191 }
188 192