Merge pull request #1107 from ispyisail/feat/lasting-wire-uuid

Give wires in older projects a lasting uuid, from what they connect
This commit is contained in:
Laurent Trinques
2026-09-28 20:19:03 +02:00
committed by GitHub
4 changed files with 345 additions and 0 deletions
+22
View File
@@ -1856,6 +1856,28 @@ bool Diagram::fromXml(QDomElement &document,
{
addItem(c);
c -> fromXml(f);
//A wire saved without a uuid got a random one that was
//never saved (#754), so it had no identity from one
//session to the next. Derive it from what it connects:
//the symbol and terminal at each end, sorted so the
//direction it was drawn in does not matter. Never its
//place in the file or its folio's index, so inserting or
//moving a folio, or saving the wires in another order,
//does not change it. It is saved from now on, so
//re-connecting the wire later keeps it; derivedItemUuid()
//never hands out a uuid the file already carries, so a
//wire later drawn on the ends it left gets another one.
if (consider_informations && m_project
&& QUuid(f.attribute(QStringLiteral("uuid"))).isNull()) {
auto end = [](const Terminal *t) {
return t->parentElement()->uuid().toString()
+ QLatin1Char('/') + t->stableUuid().toString();
};
QStringList ends{end(p1), end(p2)};
ends.sort();
c->setUuid(m_project->derivedItemUuid(QStringLiteral("conductor"),
ends.join(QLatin1Char('\n'))));
}
added_conductors << c;
}
else
+1
View File
@@ -80,6 +80,7 @@ class Conductor : public QGraphicsObject
ConductorTextItem *textItem() const;
QUuid uuid() const {return m_uuid;}
void newUuid() {m_uuid = QUuid::createUuid(); m_persist_uuid = true;} //create new uuid for this conductor
void setUuid(const QUuid &uuid) {m_uuid = uuid; m_persist_uuid = true;} //saved from now on
void updatePath(const QRectF & = QRectF());
//This method do nothing, it's only made to be used with Q_PROPERTY