Creating a hierarchical sheet destroys reference designators

Bug #1789048 reported by Ron Burkey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
High
jean-pierre charras

Bug Description

(I am using the KiCad 6.0.0-rc1 nightly build.)

When you create a hierarchical sheet in eeschema using a child schematic sheet that already exists (as opposed to letting eeschema create a new, empty child sheet for you), all of the reference designators that already exist within the child sheet will be destroyed the first time you do a Save of the design.

This can be rather distressing if you've put a lot of effort into getting the reference designators just the way you need them. I understand that this behavior is probably there in the expectation that multiple copies of the same hierarchical block will be used, and will hence need to be reannotated, but that's not the only use case. In the use case of a simple multi-sheet design in which none of the sheets appears more than once (which is my use case), it is less likely to be the desired behavior.

There's a pop-up box that appears when you create the hierarchical sheet which says something to the effect that "X.sch already exists. Link to this file?". I think that this pop-up box should:

a) Warn you that linking to the existing sheet will destroy all of its reference designators;
b) Tell you that this destruction of refd's cannot be undone; and
b) Offer the option of leaving all of the reference designators intact instead of destroying them.

There are workarounds, namely copying an intact child sheet back into place after the hierarchical-sheet-creation operation has destroyed the refd's in the first copy, but I still think that at least a warning would still be useful.

Tags: eeschema
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@Ron, I assume you mean the references are cleared in the newly added sheet, not the original sheet that the new sheet was created from. If this is the case, this is the expected behavior. Otherwise every new sheet would have duplicate references from the original sheet. If the original sheet references are getting cleared, then that is a bug.

Changed in kicad:
status: New → Incomplete
Revision history for this message
Ron Burkey (rburkey) wrote : Re: [Bug 1789048] Re: Creating a hierarchical sheet destroys reference designators

On 08/27/2018 08:51 AM, Wayne Stambaugh wrote:
> @Ron, I assume you mean the references are cleared in the newly added
> sheet, not the original sheet that the new sheet was created from. If
> this is the case, this is the expected behavior. Otherwise every new
> sheet would have duplicate references from the original sheet. If the
> original sheet references are getting cleared, then that is a bug.
>
> ** Changed in: kicad
> Status: New => Incomplete
>
Perhaps this would help: Steps to reproduce:

 1. Create a new, empty project.
 2. Copy an existing schematic file, say ORIGINAL.sch into the empty
    project's folder.
 3. Open the empty project and create a hierarchical sheet that links to
    ORIGINAL.sch.
 4. Look at ORIGINAL.sch in a text editor and verify that it still has
    its reference designators.
 5. Save the project.
 6. Look at ORIGINAL.sch in a text editor and verify that all of its
    reference designators are now U?, R?, C?, etc.

Revision history for this message
Ron Burkey (rburkey) wrote :

I had been using a nightly build of KiCad from last week, so just for grins I upgraded and retried it with the most-current nightly build (6.0.0-rc1-unknown-90788a5~66~ubuntu16.04.1, release build). It has behavior identical to what I described above.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@Rone, this is the expected behavior. I suppose we could add an option to the sheet dialog to only clear the references on demand when creating sheets using existing schematic files.

Changed in kicad:
status: Incomplete → Triaged
importance: Undecided → Wishlist
Revision history for this message
Ron Burkey (rburkey) wrote :

On 08/27/2018 10:35 AM, Wayne Stambaugh wrote:
> @Rone, this is the expected behavior. I suppose we could add an option
> to the sheet dialog to only clear the references on demand when creating
> sheets using existing schematic files.
>
> ** Changed in: kicad
> Status: Incomplete => Triaged
>
> ** Changed in: kicad
> Importance: Undecided => Wishlist
>
Thanks, that's what I was hoping for.

Revision history for this message
jean-pierre charras (jp-charras) wrote :

@Wayne,
The current behavior could (and should) be enhanced.

It has also a bug: it incorrectly clears the current annotation:
If the added sheet creates a complex hierarchy (i.e. uses a schematic file already in use) the full annotation is cleared (the sheet already existing has its annotation cleared) instead of only the annotation of the new sheet.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@JP, has it always been this way? I don't recall it but I could be
remembering it wrong. You are correct the original schematic annotation
should not get cleared. Only the entries in the schematic file for the
new sheet should be set to not annotated.

On 8/29/2018 2:34 AM, jean-pierre charras wrote:
> @Wayne,
> The current behavior could (and should) be enhanced.
>
> It has also a bug: it incorrectly clears the current annotation:
> If the added sheet creates a complex hierarchy (i.e. uses a schematic file already in use) the full annotation is cleared (the sheet already existing has its annotation cleared) instead of only the annotation of the new sheet.
>

Revision history for this message
jean-pierre charras (jp-charras) wrote :

@Wayne,

The 4.0 release does not clear annotation (therefore creating duplicate references)
The 5.x clears annotation at screen level, breaking existing annotation in complex hierarchies.

The right way (perhaps) is to clear annotation only for new sheet paths (at least on request, if the user allows that), and not for screens.

Do you want me try to fix this issue?

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@JP, initially when you open a schematic as part of a complex hierarchy,
there wont be any sheet path for the new sheet so it should be easy
enough to set the new sheet path with no annotation without changing any
existing sheet path annotation. I'm not sure about annotating the new
sheet path from the existing sheet path. If a schematic has more than
one sheet path, which one do you use when creating a new sheet?

If you have time to look at, please go ahead and fix it. We definitely
should not be clearing existing sheet path information.

On 8/30/2018 7:35 AM, jean-pierre charras wrote:
> @Wayne,
>
> The 4.0 release does not clear annotation (therefore creating duplicate references)
> The 5.x clears annotation at screen level, breaking existing annotation in complex hierarchies.
>
> The right way (perhaps) is to clear annotation only for new sheet paths
> (at least on request, if the user allows that), and not for screens.
>
> Do you want me try to fix this issue?
>

Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision 181ce46b91187f3de1da31755faa3217b6909f12
https://git.launchpad.net/kicad/patch/?id=181ce46b91187f3de1da31755faa3217b6909f12

Changed in kicad:
status: Triaged → Fix Committed
assignee: nobody → jean-pierre charras (jp-charras)
Changed in kicad:
importance: Wishlist → High
Revision history for this message
jean-pierre charras (jp-charras) wrote :

@Wayne,

Could you have a look into this fix:
Any change in complex hierarchy is always tricky and make me nervous.
The fix is itself not really tricky (although it took me a bit of time to write it), but I'll be happy to have an opinion about it.

Thanks.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@JP, I did some testing and it appears to be working as expected. I did notice that this does not work when pasting a sheet from the clipboard (none of the symbol references in the pasted sheet are cleared) but this is the current behavior which I believe was overlooked in the original paste code. I would think that we would want to have the same behavior as adding a new sheet with and existing schematic file. Pasted symbol references are cleared.

I have a few minor comments on the code:

Instead of silently returning from SCH_COMPONENT::AddSheetPathReferenceEntry() when aSheetPathName is empty or already exists, please add some asserts so any calls that violate these conditions get the developers attention.

Please remove your debugging output wrapped in #if 0/#endif from SCH_SCREENS::ClearAnnotationOfNewSheetPaths()

Other than that, everything looks good. Once this is finalized, it should be merged into the 5.0 branch. Thanks!

Changed in kicad:
milestone: none → 5.0.1
Revision history for this message
jean-pierre charras (jp-charras) wrote :

@Wayne,

I missed block copy.
I just fixed this issue in Block duplicate, Block paste and issues your noticed.

I'll commit these fixes to the 5.01 branch soon, after these fixes are tested during a few days.

Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.