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: 307
Registered: February 2012
Location: Düsseldorf
Senior Member
The CDOStoreUnorderedEList changes the order of a list during remove.

This is the code of CDOStoreUnorderedEList:

    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:

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
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 message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6433
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.


Previous Topic:[CDO] Caching and explicit garbage collection
Next Topic:[CDO] Object is unexpectedly non-writable
Goto Forum:

Current Time: Mon Jun 24 21:17:08 GMT 2019

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

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

Back to the top