[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[emf-dev] EObjectObservableList incorrect diff notification
|
Hi everyone!
I have encountered a problem with ListDiff events emitted from
EObjectObservableList during multi-remove operations (clear() in
particular).
The problem (as I can see it) is in the implementation of the
Notification.REMOVE_MANY case in the Adapter created in
EObjectObservableList#firstListenerAdded()
The index computation is incorrect. It should take the removed element
into account not just blindly increment the index. (see how the diff
is calculated in WritableList#clear())
Another problem is with clear(). The notification event index will be
set to Notification.NO_INDEX which is -1. (see
NotifyingListImpl#clear())
Here is a small test to demonstrate the issue:
----
Container container = FACTORY.createContainer();
container.getComponents().add(FACTORY.createComponent());
container.getComponents().add(FACTORY.createComponent());
IObservableList list = EMFObservables.observeList(container,
PACKAGE.getContainer_Components());
Listener listener = new Listener();
list.addListChangeListener(listener);
list.clear();
assertEquals(Arrays.asList(0, 0), listener.getIndices());
----
The actual indices are [-1, 0]
The complete test project is attached.
Could you please confirm this is an issue.
Thank you!
Attachment:
notification1.zip
Description: Zip archive