Give terminals in older projects a lasting uuid

Most symbols stored in older projects have no uuid on their terminals
(706 of the 900 in the 24 examples), so a terminal's identity is worked
out from where it sits in its symbol on every load (stableUuid()). That
is only sound while nothing keyed on it is kept between loads.

- On opening a project, every terminal of its embedded symbols without a
  uuid gets that same derived value (TerminalUuids::fillMissing(), from
  XmlElementCollection's loading constructor, before any folio is
  built). The next save writes it, and the wires on it in the form that
  names terminals by uuid, which QElectroTech reads since 0.8.0.
- The recipe moves to TerminalUuids::derived(), which stableUuid() now
  calls, so the two cannot drift apart. A second terminal at the same
  point of a symbol gets the next occurrence, and no value is given
  twice within a symbol.
- findTerminal(): a wire whose terminal uuid is not found is matched to
  the terminal whose derived value it is, so a saved uuid still finds its
  terminal after the symbol's definition was replaced by one whose
  terminals carry other uuids.

The project database's terminal and conductor tables are identical before
and after on all 24 examples except the 3 terminals that share a point
with another in their symbol (industrial.qet 1, perceuse.qet 2), which
now have an identity of their own. Every example keeps every wire through
a resave, and a second save changes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-29 08:50:27 +13:00
parent 079d085a87
commit 4e6f59e011
7 changed files with 299 additions and 27 deletions
@@ -128,9 +128,13 @@ XmlElementCollection::XmlElementCollection(const QDomElement &dom_element,
QObject(project),
m_project(project)
{
if (dom_element.tagName() == "collection")
if (dom_element.tagName() == "collection") {
m_dom_document.appendChild(m_dom_document.importNode(
dom_element, true));
//Before any folio is built from these symbols, so that their
//terminals carry the uuid the next save writes
TerminalUuids::fillMissing(root());
}
else
qDebug() << "XmlElementCollection : tagName of dom_element is not collection";
}