diff --git a/sources/diagramcommands.cpp b/sources/diagramcommands.cpp index ce9a62f25..6af19b773 100644 --- a/sources/diagramcommands.cpp +++ b/sources/diagramcommands.cpp @@ -80,9 +80,13 @@ void DeleteElementsCommand::undo() { foreach(Element *e, removed_content.elements) { diagram -> addItem(e); - //Relink this element with other - foreach (Element *elmt, m_link_hash[e]) - e -> linkToElement(elmt); + } + + //We relink element after every element was added to diagram + foreach(Element *e, removed_content.elements) { + foreach (Element *elmt, m_link_hash[e]) { + e -> linkToElement(elmt); + } } foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {