Mailing list archives : pcb-rnd

ID:3669
From:ge...@igor2.repo.hu
Date:Sun, 12 Jan 2020 10:04:37 +0100 (CET)
Subject:Re: [pcb-rnd] project state update
in-reply-to:3661 from Gabriel Paubert <pa...@iram.es>
replies: 3671 from Gabriel Paubert <pa...@iram.es>
Hi Gabriel,
 
On Sat, 11 Jan 2020, Gabriel Paubert wrote:
 
>	Hi,
 
<snip>
 
>But there is a much more serious bug related to undo, to reproduce:
>- load the attached file in pcb-rnd
>- move the polygon, say somewhat right and down
>- undo (Ctrl-Z)
>- result is fine
>- select the polygon
>- move it again
>- undo 
>- some red lines appear in the message window, so at least pcb-rnd is
>  aware that something is wrong
>- problem: now there are two copies of the polygon
>- try to undo again and this becomes a mess, you may end up with 3
>  polygons
>
>It has taken me some time to find a way to reproduce the problem on a
>fairly simple test case. I've been bitten by many undo issues for about
>two weeks, for example duplicated subcircuits.
>
>I believe now that the problem is related to undo and selection, but 
>I'm not 100% sure.
 
Thanks! Yes, the bug happened when you moved a selected object.  Minimal 
test recipe: empty board, place a rectangle on top copper, select, 
drag&drop move, {u u}.
 
Fixed in r29149, please test!
 
Boring bug details:
 
For various (inherited) reasons, this is really a cut&paste through a 
buffer. We used to have a bug about this: even tho it was a hardwired cut 
& paste with the buffer cleared afterward (so you don't have the chance to 
paste multiple copies this way), the operation allocated new object IDs 
for the pasted objects.
 
This was always a problem, but a weak one, nobody detected or reported it, 
but it constantly caused unreasonable nosie to board file diffs. I noticed 
this bug when working on the first version of extended objects where my 
objects had to keep references to other objects so chaning IDs was fatal. 
So I went and fixed it in a series of commits back in 2019-12-13.
 
However, the fix was not perfect. There is one other subsystem that 
heavily depends on object IDs: the undo system. The original fix modified 
the object ID after the objects got added to the undo with a temporary 
ID. 
 
So the exact way your test case failed: the undo tried to remove the 
polygon placed in the paste part of your selected-move (cut&paste really) 
operation, but since it remembered it by the wrong ID, it failed; the 
other operation to undo was the cut, where the ID was not ruined so that 
worked, that's why you got both polygons kept.
 
Regards,
 
Igor2
 
 

Reply subtree:
3669 Re: [pcb-rnd] project state update from ge...@igor2.repo.hu
  3671 Re: [pcb-rnd] project state update from Gabriel Paubert <pa...@iram.es>