Danny Shevitz | 17 Jul 18:49

problem with undo on delegated lists

howdy,

Another problem with delegation here. I believe it's a bug, but I always do 
and I'm usually wrong :-).

If a list is delegated as in

class A
 sub_nodes = List

class B
 a = Instance(A)
 sub_nodes = Delegate('a', modify=True)

Now imagine two instances of B share the same a

a = A()
b1 = B(a=a)
b2 = B(a=a)

so the b's are different but b1.a = b2.a = a.

Now the problem. If I change "a" (via "b", in a gui so we have an undo history),
then the undo history is appended with an undo item containing two changes, one
for b1 and one for b2. In fact there was only one change to the delegatee, "a".

If I do an undo/redo operation on the tree (via the default buttons) then
changes are made to both b1 and b2 resulting in twice as many changes to a.
So if I append to b1 and do an undo/redo I now end with two children under
both b1 and b2, when I should only have one.

I'm not sure where it belongs or how to implement it,  but the solution is 
conceptually clear. If a list is delegated and modify='true' then you should
only create an undo item for the delegatee, not the delegators. 

This is probably also happening for other things besides delegated lists but
I would guess it is happening for all delegated containers.

thanks,
D

Gmane