Clear stale xref data from PLC slave elementInformations on unlink and position change

This commit is contained in:
Kellermorph
2026-09-14 12:04:17 +02:00
parent 2785e25569
commit 00e75604b0
4 changed files with 42 additions and 0 deletions
@@ -764,6 +764,8 @@ QVariant DynamicElementTextItem::itemChange(QGraphicsItem::GraphicsItemChange ch
if(m_parent_element.data()->linkType() == Element::Slave)
{
connect(m_parent_element.data(), &Element::linkedElementChanged, this, &DynamicElementTextItem::masterChanged);
if(m_parent_element.data()->diagram())
connect(m_parent_element.data()->diagram()->project(), &QETProject::XRefPropertiesChanged, this, &DynamicElementTextItem::updateXref);
//The parent is already linked, wa call master changed for init the connection
if(!m_parent_element.data()->linkedElements().isEmpty())
masterChanged();
@@ -1497,6 +1499,18 @@ void DynamicElementTextItem::updateXref()
}
}
}
//Remove stale "xref" from elementInformations when no longer needed
if(m_parent_element->linkType() == Element::Slave &&
m_text_from == ElementInfo && m_info_name == "xref")
{
DiagramContext dc = m_parent_element->elementInformations();
if(!dc.value("xref").toString().isEmpty())
{
dc.remove("xref");
m_parent_element->setElementInformations(dc);
}
}
}
void DynamicElementTextItem::setPlainText(const QString &text)