diff --git a/sources/elementspanelwidget.cpp b/sources/elementspanelwidget.cpp index 7baf0afbe..0fdc60edb 100644 --- a/sources/elementspanelwidget.cpp +++ b/sources/elementspanelwidget.cpp @@ -17,6 +17,7 @@ */ #include "elementspanelwidget.h" #include "diagram.h" +#include "qetgraphicsitem/conductor.h" #include "editor/ui/qetelementeditor.h" #include "elementscategoryeditor.h" #include "qetapp.h" @@ -652,6 +653,13 @@ void ElementsPanelWidget::duplicateDiagram() elmt->newUuid(); new_diagram->restoreText(elmt); } + else if (Conductor *cond = dynamic_cast(item)) { + // Same reasoning for conductors: conductor.uuid is the PRIMARY + // KEY of the conductor table, and its insert is a plain INSERT, + // so a duplicated uuid fails and the wire silently disappears + // from the wiring list and the per-element wire count. + cond->newUuid(); + } } } diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 546f64b3e..e04288107 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1010,7 +1010,13 @@ bool Conductor::fromXml(QDomElement &dom_element) //generate one on load, same treatment terminal uuids got when //that field was introduced (see terminal1/terminal2 handling in //toXml() below). - m_uuid = QUuid(dom_element.attribute("uuid", QUuid::createUuid().toString())); + m_uuid = QUuid(dom_element.attribute(QStringLiteral("uuid"))); + if (m_uuid.isNull()) { + //Absent, empty or malformed: mint one. A null uuid is not a usable + //identity -- every conductor carrying one would collide with every + //other on the conductor table's primary key. + m_uuid = QUuid::createUuid(); + } setPos(dom_element.attribute("x", nullptr).toDouble(), dom_element.attribute("y", nullptr).toDouble());