Skip to content

Fix #413: paste no longer adds '_' label to conductors that had no label - #523

Open
ispyisail wants to merge 1 commit into
qelectrotech:masterfrom
ispyisail:fix/paste-conductor-empty-label
Open

Fix #413: paste no longer adds '_' label to conductors that had no label#523
ispyisail wants to merge 1 commit into
qelectrotech:masterfrom
ispyisail:fix/paste-conductor-empty-label

Conversation

@ispyisail

Copy link
Copy Markdown
Contributor

Problem

When erase-label-on-copy is enabled (the default), copy-pasting conductors that had no label (num="") caused them to gain a _ label on the paste. The user's original conductor was visually clean (no text), but every copy came out labelled, requiring manual cleanup.

Root cause (traced through the code)

PasteDiagramCommand::redo() in diagramcommands.cpp reset every pasted conductor to the diagram's default text:

cp.text = c->diagram() ? c->diagram()->defaultConductorProperties.text : "_";

ConductorProperties initialises text to "_" by default (conductorproperties.cpp:246), so diagram->defaultConductorProperties.text is "_" unless the user has explicitly changed it in Project/Diagram Properties. A conductor that arrived from the clipboard with text = "" (from num="") was unconditionally overwritten with "_".

Additionally the conductor-reset loop was nested inside the per-element loop, so with N pasted elements the conductors were reset N times (harmless but wasteful).

Fix

Two changes in diagramcommands.cpp:

  1. Move the conductor-reset loop outside the per-element loop — runs once per paste, not once per element.
  2. Guard the reset: only reset conductors that already carried a non-empty label. Conductors with text == "" keep their empty label after paste.
if (!cp.text.isEmpty())
    cp.text = diagram->defaultConductorProperties.text;

This preserves the existing behaviour for labelled conductors (they are cleared to the diagram default so autonumbering can renumber them), while leaving blank conductors alone.

Test plan

  • Draw two elements, connect with a conductor, leave the conductor label empty. Copy+paste — pasted conductor should have no label.
  • Same setup but give the conductor a label (e.g. "L1"). Copy+paste with erase-label-on-copy enabled — pasted conductor should be reset to the diagram default (usually _).
  • Undo/redo the paste — behaviour should be stable.
  • Multiple elements pasted at once — conductor reset should happen once, not N times.

Fixes #413.

🤖 Generated with Claude Code

When erase-label-on-copy is enabled, PasteDiagramCommand::redo() reset
all pasted conductors to the diagram default text (typically "_"), even
conductors that originally had an empty label (""). This silently enrolled
them in autonumbering against the user's intent, causing confusion.

Two changes:
- Move the conductor-reset loop outside the per-element loop so it runs
  once per paste rather than once per pasted element.
- Guard the reset with `!cp.text.isEmpty()`: conductors with no label
  keep their empty label; only conductors that carried a real label are
  reset to the diagram default so they can be renumbered.

Fixes qelectrotech#413.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@scorpio810

Copy link
Copy Markdown
Contributor

Hello @ispyisail have you tryed to remove underscore for default conduction in ,new diagram folio in project setingss, berore? maybe we could delete underscore for conductor 's labels.

@scorpio810

Copy link
Copy Markdown
Contributor

I ’m fed up with seeing beginners’ projects everywhere with underscores all over the place around the QET conductors...

@ispyisail

Copy link
Copy Markdown
Contributor Author

You need to decide how you want it to work, maybe you happy with the exiting code/function? I have provided an alternative which you can reject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy-pasting conductors without labels adds a _ label

2 participants