Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 342603

Summary: Use of SetCommand with List lead to a wrong result
Product: [Modeling] EMF Reporter: Nicolas Guyomar <nicolas.guyomar>
Component: EditAssignee: Ed Merks <Ed.Merks>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.7.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 337408    
Attachments:
Description Flags
Junit Test plugin to reproduce the bug
none
Patches to address the issue. none

Description Nicolas Guyomar CLA 2011-04-12 12:02:28 EDT
Created attachment 193062 [details]
Junit Test plugin to reproduce the bug

Hi,

While using EMF Command, I wanted to sort a list of elements before using a SetCommand to set the resulting list to an EObject. 

The sort result is ok, but during the SetCommand something goes wrong and the following happens : 

- the elements which where already in the "correct" sorted position (before the sort) are not accurately placed after the command execution.

I think it has something to do with the use of MoveCommand in the implementation of SetCommand, because this bug only happens if I create the SetCommand using SetCommand.create(...) and not with a "usual" instanciation "new SetCommand()"

Because I do not really know how to express this bug in a better way, I reproduced both instantiation scenarios using an UML Class and some properties in the attached JUnit plug-in test.

Regards,
Nicolas Guyomar

http://www.eclipse.org/modeling/emft/facet/
http://www.eclipse.org/MoDisco/
Comment 1 Ed Merks CLA 2011-04-12 13:11:55 EDT
Created attachment 193076 [details]
Patches to address the issue.

It looks like it's important to keep the list of remainingValues that we're using to analyze which objects need to be moved in sync with the moves that will be done by the actual move commands.  Could you verify this solves the problem; it makes the test pass. 

Thanks for making it so easy to reproduce the problem!
Comment 2 Nicolas Guyomar CLA 2011-04-13 03:17:24 EDT
Hi Ed,

Thank you for the patch, it solves my problem with the SetCommand.

Would that patch be applied for 3.6 M7 ?

Regards,
Nicolas Guyomar
Comment 3 Ed Merks CLA 2011-04-13 11:11:27 EDT
The fix is committed to CVS for 2.7.  It will be in the M7 build.
Comment 4 Ed Merks CLA 2011-05-10 11:57:51 EDT
The changes are available in EMF 2.7 M7 or an earlier build.