Symbol editor: imported elements get new terminal uuids

Review of the previous commit: "Import scaled element" and "Import DXF"
add a definition to an open symbol through OpenElmtCommand, which, unlike
a paste, kept the imported terminals' uuids. With derived uuids, an old
symbol imported into itself (or into another with a terminal at the same
point) gave two terminals one uuid; importing any symbol whose terminals
already carried uuids did the same before this series. OpenElmtCommand now
renews the imported terminals' uuids, as PastePartsCommand does.

Checked in the editor with a stand-in scaler at scale 1: open
6es7_212-1ae40-0xb0__p3.elmt, import it into itself, save -- 6 terminals,
3 distinct uuids without this commit, 6 with it, the original 3 keeping
their derived values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-29 09:55:27 +13:00
parent 2815dbaf47
commit 22f1455868
@@ -17,6 +17,7 @@
*/
#include "openelmtcommand.h"
#include "../elementscene.h"
#include "../graphicspart/partterminal.h"
#include <QDomDocument>
#include <QObject>
@@ -52,6 +53,15 @@ void OpenElmtCommand::redo()
if (m_first_redo)
{
m_scene->fromXml(m_document, QPointF(), true, &m_graphics_item);
//The terminals are added to an element that may already hold
//the same ones -- importing the same symbol twice, or two old
//symbols whose terminals get the same derived uuid -- so they
//get new uuids, as a paste gives them (PastePartsCommand).
for (QGraphicsItem *qgi : std::as_const(m_graphics_item)) {
if (qgi->type() == PartTerminal::Type) {
static_cast<PartTerminal *>(qgi)->setNewUuid();
}
}
m_scene->qgiManager().manage(m_graphics_item);
m_first_redo = false;