autoBreakConductors: share conductors_handled/used_terminals across batch

When multiple elements are pasted or moved in one batch, each call to
autoBreakConductors() now receives the shared state from the previous
call.  This prevents two elements in the same batch from independently
claiming the same conductor, which would result in a double-delete on
redo().

Requested by ispyisail in PR review.
This commit is contained in:
Kellermorph
2026-08-09 09:11:40 +02:00
parent 39b1e836bf
commit d95e744494
5 changed files with 30 additions and 13 deletions
@@ -265,7 +265,10 @@ void DiagramEventAddElement::addElement()
//Auto break conductor: if a terminal of the new element lies on an existing
//conductor, break the conductor and reconnect through the new element's terminal.
//Track the endpoints of broken conductors so auto-connect doesn't create duplicates.
QSet<Terminal *> broken_endpoints = autoBreakConductors(m_diagram, element, undo_object);
QList<Conductor *> conductors_handled;
QSet<Terminal *> used_terminals;
QSet<Terminal *> broken_endpoints = autoBreakConductors(m_diagram, element, undo_object,
conductors_handled, used_terminals);
//Auto-connect: collect all aligned pairs first, then filter and process.
QList<QPair<Terminal *, Terminal *>> aligned_pairs;