auto-uref is broken

Bug #787637 reported by KaiMartin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gEDA
Fix Released
Medium
Unassigned

Bug Description

The auto-uref.scm script does not work as expected. It uses even numbers only and produces duplicate refdeses.

To reproduce:

0) add these lines in gschemrc to activate auto-uref:
   (load-from-path "auto-uref.scm")
   (add-hook! add-component-hook auto-uref)
   (add-hook! copy-component-hook auto-uref)

1) open gschem.

2) Open the symbol chooser dialog and add three symbols resistor-2.sym from the Basic_devices library.

Refdeses should be R1, R2, R3, but will be R2, R4, R6.

3) save the sheet with save-as.

4) close gschem.

5) open gschem with the saved sheet.

6) Add some more resistor-1.sym via the chooser dialog.

Refdeses will again be R2, R4, R6, etc. That is, duplicates to the symbols already present on the sheet.

---<)kaimartin(>---

Tags: gschem scheme
description: updated
tags: added: gschem scheme
Changed in geda:
status: New → Confirmed
importance: Undecided → Medium
Changed in geda:
assignee: nobody → Krzysztof Kościuszkiewicz (k-kosciuszkiewicz)
Revision history for this message
KaiMartin (kmk-familieknaak) wrote :

This is probably related:
The auto-uref script does not seem to do anything on copy/paste. To reproduce:

0) activate the auto-uref hook in gschemrc

1) open gschem

2) add a resistor symbol. Its refdes will be set to R2 by the hook

3) select the resistor symbol and copy to buffer with [ctrl-c]

4) paste the buffer with [ctrl-v]+[click-on-canvas]

The refdes of the copied symbol is R2. It should be R3.
(Thanks to Krzysztof for adopting this bug.)

---<)kaimartin(>---

Revision history for this message
Krzysztof Kościuszkiewicz (k-kosciuszkiewicz) wrote :

You need to use "copy" command to have refdeses updated on pasted objects.
Gschem does not know if the buffer contents came from a CTRL-C or CTRL-X operation - so for objects in the buffer refdeses are not updated.

Revision history for this message
Krzysztof Kościuszkiewicz (k-kosciuszkiewicz) wrote :

I have modified the script to 1) keep track of the refdeses per page and 2) check existing refdeses when page is opened/created.
Changes can reviewed/fetched here: http://repo.or.cz/w/geda-gaf/kokr.git/shortlog/refs/heads/auto-uref

Revision history for this message
KaiMartin (kmk-familieknaak) wrote :

What is the difference between the copy action and [ctrl-c]? Wouldn't gschem be able to replace the number by a questionmark character on [ctrl-c]? A paste would then replace the "?" with the auto generated number.

By the way: I'd welcome a hook that would only do the first of the above steps. That is, unnumber the symbols that were copied (with [ctrl-c]). This would avoid duplicates but still allow for full user control over the new numbers.

---<)kaiamrtin(>---

Revision history for this message
Krzysztof Kościuszkiewicz (k-kosciuszkiewicz) wrote :

Right now it's a separate operation. In principle it could work the way you have mentioned, ie. hooks for copy, cut and paste could be provided. But I think this falls into "Wishlist" category ;)

Revision history for this message
Peter Clifton (pcjc2) wrote :

Regarding KMK's second point in comment #4, I use the attached hook for renaming to "U?" etc..

Revision history for this message
Peter Clifton (pcjc2) wrote :
Revision history for this message
Krzysztof Kościuszkiewicz (k-kosciuszkiewicz) wrote :
Changed in geda:
status: Confirmed → Fix Committed
assignee: Krzysztof Kościuszkiewicz (k-kosciuszkiewicz) → nobody
Revision history for this message
KaiMartin (kmk-familieknaak) wrote :

Thanks. No autonumber works as expected on add-component. It does not work on copy. No matter how I copy, the refdes stays the same on paste (yp, [ctrl-c], edit menu). I can't get Peters script to work, either. Feels like the copy-copy-component-hook just does nothing.

This are the gschemrc lines by which I try to activate renumber on copy:

(load-from-path "auto-uref.scm")
(load-from-path "unnumber-refdes.scm")
;(add-hook! copy-component-hook unnumber-refdes)
(add-hook! new-page-hook auto-uref-init-page)
(add-hook! add-component-hook auto-uref)
(add-hook! copy-component-hook auto-uref)

---<)kaimartin(>---

Revision history for this message
KaiMartin (kmk-familieknaak) wrote :

Why can't I edit my comment above? No edit buttons there...
The second sentence was meant to start like this: "Now, autonumber works ..."

---<)kaimartin(>---

Revision history for this message
Peter TB Brett (peter-b) wrote :

On Thursday 26 May 2011 02:14:18 KaiMartin wrote:
> What is the difference between the copy action and [ctrl-c]? Wouldn't
> gschem be able to replace the number by a questionmark character on
> [ctrl-c]? A paste would then replace the "?" with the auto generated
> number.
>

Eww. That breaks quite a lot of the assumptions that users would
normally expect with copy/paste. It would also break user expectations
when pasting to other applications, something that Peter C. and I spent
quite a lot of time thinking about how to support (he has an example
patch somewhere that enables copying from gschem and pasting SVG
graphics into Inkscape). We already support copying from gschem and
pasting into a text editor, by the way.

In general, I'm not totally comfortable with the way that auto-uref
keeps its own table of data which is not guaranteed to match up with the
reality of what's going on in the page. Wouldn't all these problems be
solved if the script just scanned the page each time it needed a new
refdes instead of caching its own often-out-of-date data?

                              Peter

--
Peter Brett <email address hidden>
Remote Sensing Research Group
Surrey Space Centre

Peter TB Brett (peter-b)
Changed in geda:
milestone: none → 1.7.1
Peter TB Brett (peter-b)
Changed in geda:
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.