Merge pull request #846 from ispyisail/fix/titleblock-template-save-order

Write embedded title block templates in a stable order
This commit is contained in:
ispyisail
2026-09-13 00:52:39 +12:00
committed by GitHub
+8 -1
View File
@@ -1043,7 +1043,14 @@ QDomDocument QETProject::toXml()
// titleblock templates, if any
if (m_titleblocks_collection.templates().count()) {
QDomElement titleblocktemplates_elmt = xml_doc.createElement("titleblocktemplates");
foreach (QString template_name, m_titleblocks_collection.templates()) {
//Sorted, because templates() returns QHash::keys() and Qt
//randomises hash order per process. Writing them unsorted put the
//<titleblocktemplate> children in a different order on every save,
//which is what made a project holding more than one template save
//irreproducibly.
QStringList template_names = m_titleblocks_collection.templates();
template_names.sort();
for (const QString &template_name : std::as_const(template_names)) {
QDomElement e = m_titleblocks_collection.getTemplateXmlDescription(template_name);
titleblocktemplates_elmt.appendChild(xml_doc.importNode(e, true));
}