From 22f1455868f0cc88df4317ac703a429a85525466 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Tue, 29 Sep 2026 09:55:27 +1300 Subject: [PATCH] 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 --- sources/editor/UndoCommand/openelmtcommand.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sources/editor/UndoCommand/openelmtcommand.cpp b/sources/editor/UndoCommand/openelmtcommand.cpp index f94ab4c2f..ff28b4adc 100644 --- a/sources/editor/UndoCommand/openelmtcommand.cpp +++ b/sources/editor/UndoCommand/openelmtcommand.cpp @@ -17,6 +17,7 @@ */ #include "openelmtcommand.h" #include "../elementscene.h" +#include "../graphicspart/partterminal.h" #include #include @@ -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(qgi)->setNewUuid(); + } + } m_scene->qgiManager().manage(m_graphics_item); m_first_redo = false;