Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] CDOStoreUnorderedEList invalidates index of RemoveCommand during undo
[CDO] CDOStoreUnorderedEList invalidates index of RemoveCommand during undo [message #1794266] Tue, 28 August 2018 10:53 Go to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
The CDOStoreUnorderedEList changes the order of a list during remove.

This is the code of CDOStoreUnorderedEList:

   @Override
    public E remove(int index)
    {
      boolean oldObjectIsLast = index == size() - 1;
      E oldObject = super.remove(index);

      if (!oldObjectIsLast)
      {
        move(index, size() - 1);
      }

      return oldObject;
    }


A move is performed if the removed object was not the last object in the list.
Since a RemoveCommand stores its remove indices in the owing list for undoing, this additional move destroys the ability to properly undo RemoveCommands.

Consider the following list of objects in an CDOStoreUnorderedEList. For simplicity the objects in the list are represented by their id:

Initial List:
1,2,3

Add element 4 -> 1,2,3,4
Remove Element 1:  4,2,3 (this changed order is due to the additional move)
Remove Element 4: -> 3,2  (this changed order is due to the additional move)

undo: 4,3,2 (The undo of RemoveCommand inserts 4 at position 0)
undo: 1,4,3,2 (The undo of RemoveCommand inserts 1 at position 0)
undo: 1,4,3 (The undo of AddCommand removes element at position 3)


So we end up with a list that contains elements 1,4,3 instead of 1,2,3.

I am quite sure that this is a bug and I do not see a reason for this additional move. If the move is skipped everything works just fine.

Any thoughts on this?

Thanks in advance
Thorsten
Re: [CDO] CDOStoreUnorderedEList invalidates index of RemoveCommand during undo [message #1800858 is a reply to message #1794266] Wed, 09 January 2019 08:08 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Thorsten,

I think the unordered list optimization just doesn't work together with higher-level undos. Please submit a bugzilla, so that I can disable this optimization by default.

Cheers
/Eike


Re: [CDO] CDOStoreUnorderedEList invalidates index of RemoveCommand during undo [message #1814558 is a reply to message #1800858] Fri, 13 September 2019 08:22 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
I have now disabled the optimization in the context of https://bugs.eclipse.org/bugs/show_bug.cgi?id=551035 !

Previous Topic:Single references of EObject type in Dynamic Model
Next Topic:Help Embedding EMF in a Java Based Project in Eclipse
Goto Forum:
  


Current Time: Thu Apr 25 14:20:16 GMT 2024

Powered by FUDForum. Page generated in 0.02829 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top