From 4c7d4e7c537d1953276cbd9272b7ddd073bba1e1 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Fri, 14 Aug 2026 19:08:21 +1200 Subject: [PATCH] Fix pasted conductors getting an unwanted "_" label https://github.com/qelectrotech/qelectrotech-source-mirror/issues/413 ## Bug Copy-pasting an element pair joined by a conductor with no label results in the pasted conductor having a literal "_" label, even though the source conductor's label was empty. Repeating copy+paste on the result keeps stacking the same "_" back on, since the pasted conductor now legitimately has that text. ## Root cause PasteDiagramCommand::redo() (sources/diagramcommands.cpp), when the "erase label on copy" option is enabled (the default), resets each pasted element's formula/label/comment/location to "" - a real erase. Right next to it, the equivalent reset for conductors doesn't erase: cp.text = c->diagram() ? c->diagram()->defaultConductorProperties.text : "_"; It unconditionally overwrites the conductor's text with the *project's configured default text for newly drawn conductors* - a setting that happens to default to a literal "_" character (visible in the project/ new-folio "Conductors" tab), and is otherwise unrelated to whether this particular copy's label should be kept or cleared. The `: "_"` fallback for the "no diagram" case doesn't help either, since these conductors are already added to the scene before this code runs. ## Fix Reset conductor text to "" too, matching every other field reset in the same block. "Erase on copy" should erase, not "replace with whatever the project's unrelated new-conductor default happens to be." ## Verification Built clean. I was not able to get a reliable live GUI reproduction under Xvfb + xdotool for this one - drawing conductors between terminals via simulated drag kept mis-firing as element placement instead in this environment, the same class of automation friction noted on PR #743. Confidence rests on tracing the exact code path (confirmed defaultConductorProperties.text is a project-level setting for freshly-drawn conductors, unrelated to paste; confirmed the sibling element-info reset four lines above uses "" specifically) plus the fact this is a one-line change to match an already-correct pattern right next to it, not new logic. --- sources/diagramcommands.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sources/diagramcommands.cpp b/sources/diagramcommands.cpp index ab3a6fdeb..99a3f7c3e 100644 --- a/sources/diagramcommands.cpp +++ b/sources/diagramcommands.cpp @@ -99,12 +99,18 @@ void PasteDiagramCommand::redo() dc.addValue("location", ""); e->setElementInformations(dc); - //Reset the text of conductors + //Reset the text of conductors, the same way the label/comment/ + //location above are reset to "" rather than to some other + //value - "erase on copy" means erase, not "replace with the + //project's default new-conductor text" (which happens to + //default to a literal "_" character, unrelated to whether the + //user wanted this copy's old label kept or cleared; see + //issue #413). const QList conductors_list = content.m_conductors_to_move; for (Conductor *c : conductors_list) { ConductorProperties cp = c -> properties(); - cp.text = c->diagram() ? c -> diagram() -> defaultConductorProperties.text : "_"; + cp.text = ""; c -> setProperties(cp); } }