mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-05 02:24:13 +02:00
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:
@@ -300,6 +300,29 @@ private slots:
|
||||
QCOMPARE(TerminalUuids::fillMissing(root), 0);
|
||||
}
|
||||
|
||||
// The element editor fills a definition read from a file with exactly
|
||||
// what a project fills the same definition with.
|
||||
void fillMissingInDefinitionMatchesProject()
|
||||
{
|
||||
QDomDocument doc;
|
||||
const QString own = QStringLiteral("{0f5d4b0c-2f7e-4a55-9a51-8c3a3e1c2d11}");
|
||||
QDomElement in_project = symbol(doc, {{"0", "10", "s"},
|
||||
{"0", "10", "s"},
|
||||
{"5", "0", "e", own},
|
||||
{"-3", "0", "w"}});
|
||||
QDomElement root = doc.createElement(QStringLiteral("collection"));
|
||||
root.appendChild(in_project);
|
||||
QDomElement definition = in_project.firstChildElement(QStringLiteral("definition"))
|
||||
.cloneNode(true).toElement();
|
||||
|
||||
QCOMPARE(TerminalUuids::fillMissingInDefinition(definition), 3);
|
||||
QCOMPARE(TerminalUuids::fillMissing(root), 3);
|
||||
QCOMPARE(uuids(definition), uuids(in_project));
|
||||
QCOMPARE(uuids(definition).at(2), own);
|
||||
QCOMPARE(uuids(definition).at(1), TerminalUuids::derived(0, 10, 2, 1).toString());
|
||||
QCOMPARE(TerminalUuids::fillMissingInDefinition(definition), 0);
|
||||
}
|
||||
|
||||
// An example whose symbols have no terminal uuids and whose wires are
|
||||
// all in the numbered form: once saved, every terminal has a uuid,
|
||||
// every wire names its ends by uuid, nothing is lost, and saving again
|
||||
|
||||
Reference in New Issue
Block a user