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
+3 -4
View File
@@ -71,16 +71,15 @@ qreal distanceToSegment(const QPointF &point, const QLineF &segment)
QSet<Terminal *> autoBreakConductors(
Diagram *diagram,
Element *element,
QUndoCommand *parent)
QUndoCommand *parent,
QList<Conductor *> &conductors_handled,
QSet<Terminal *> &used_terminals)
{
QSet<Terminal *> broken_endpoints;
if (!diagram->project()->autoBreakConductor())
return broken_endpoints;
QList<Conductor *> conductors_handled;
QSet<Terminal *> used_terminals;
foreach (Terminal *t, element->terminals())
{
if (used_terminals.contains(t))