Symbol editor: give old terminals their derived uuid, not a random one

A symbol file whose terminals have no uuid got a random one for each
terminal when opened in the element editor (PartTerminal's constructor),
written on save. Every copy of the same old symbol therefore ended up
with different terminal uuids, none of them the one a project gives the
same terminals on opening (TerminalUuids::fillMissing()).

ElementScene::loadContent() now reads a copy of the definition filled by
TerminalUuids::fillMissingInDefinition(), the same rule as a project,
including the next occurrence for the second of two terminals at one
point. Terminals that have a uuid keep it; a paste still renews them all
(PastePartsCommand).

Checked in the editor: 6es7_212-1ae40-0xb0__p3.elmt (no terminal uuids
in the collection) and tm3saf5r_layout.elmt with its uuids stripped (two
terminals at one point), opened, nudged back and forth, saved: this build
writes exactly the derived values (computed independently in Python),
the previous one random ones. Select all, copy, paste, save: 6 terminals,
6 distinct uuids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-29 09:37:57 +13:00
parent 90084ecf40
commit 2815dbaf47
4 changed files with 60 additions and 8 deletions
+8
View File
@@ -17,6 +17,7 @@
*/
#include "elementscene.h"
#include "../ElementsCollection/terminaluuids.h"
#include "../NameList/ui/namelistdialog.h"
#include "../NameList/ui/namelistwidget.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
@@ -1196,6 +1197,13 @@ ElementContent ElementScene::loadContent(const QDomDocument &xml_document)
if (root.tagName() != "definition" || root.attribute("type") != "element")
return(loaded_parts);
//Terminals saved without a uuid get the one a project gives them
//(see TerminalUuids::fillMissing()), not a random one: the same old
//symbol then has the same terminal uuids wherever it is copied.
//On a copy, the document is the caller's. A paste renews them all.
root = root.cloneNode(true).toElement();
TerminalUuids::fillMissingInDefinition(root);
//Load the graphic description of the element
for (QDomNode node = root.firstChild() ; !node.isNull() ; node = node.nextSibling())
{