diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.cpp b/sources/qetgraphicsitem/dynamicelementtextitem.cpp index 9a2b67d25..db6340114 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.cpp +++ b/sources/qetgraphicsitem/dynamicelementtextitem.cpp @@ -1470,11 +1470,12 @@ void DynamicElementTextItem::updateXref() m_Xref_item = nullptr; } + m_update_slave_Xref_connection.clear(); + if(m_slave_Xref_item) { delete m_slave_Xref_item; m_slave_Xref_item = nullptr; - m_update_slave_Xref_connection.clear(); //If position changed to Champ de texte, store xref in element info if(m_parent_element->linkType() == Element::Slave && diff --git a/sources/qetgraphicsitem/elementtextitemgroup.cpp b/sources/qetgraphicsitem/elementtextitemgroup.cpp index 9adade296..a9cdeb6c0 100644 --- a/sources/qetgraphicsitem/elementtextitemgroup.cpp +++ b/sources/qetgraphicsitem/elementtextitemgroup.cpp @@ -873,11 +873,12 @@ void ElementTextItemGroup::updateXref() delete m_Xref_item; m_Xref_item = nullptr; } + m_update_slave_Xref_connection.clear(); + if(m_slave_Xref_item) { delete m_slave_Xref_item; m_slave_Xref_item = nullptr; - m_update_slave_Xref_connection.clear(); //If position changed to Champ de texte, store xref in element info if(m_parent_element->linkType() == Element::Slave && diff --git a/sources/ui/plclinkwidget.cpp b/sources/ui/plclinkwidget.cpp index 144ee0bff..545c68b1b 100644 --- a/sources/ui/plclinkwidget.cpp +++ b/sources/ui/plclinkwidget.cpp @@ -355,6 +355,20 @@ void PlcLinkWidget::on_m_unlink_pb_clicked() return; LinkElementCommand *undo = new LinkElementCommand(m_element); + + // Store the current group index so makeLink() can + // restore PLC variables and terminal labels on undo. + for (Element *elmt : m_element->linkedElements()) + { + if (elmt->linkType() == Element::Master) + { + int idx = elmt->groupIndexForElement(m_element); + if (idx >= 0) + undo->setGroupIndex(idx); + break; + } + } + undo->unlinkAll(); m_element->diagram()->undoStack().push(undo);