[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] [Databinding] updateTargets() appends model list to target list

The following code fragment creates a model list which is [1,2] before binding,
and a target list which is initially []. After binding it is also [1,2]. If
I call ctx.updateTargets() right after bindList() I expect it to do nothing,
because the lists are equal. But it appends the model list to the target list
yielding obsTargetList == [1,2,1,2]. Looks like a bug for me.

// create observable model list [1,2]
ArrayList<Integer> modelList = new ArrayList<Integer>();
modelList.add(1);
modelList.add(2);
WritableList obsModelList = new WritableList(realm, modelList, Integer.class);
System.out.println("before binding, obsModelList: " + obsModelList);

// create observable target list []
ArrayList<Integer> targetList = new ArrayList<Integer>();
WritableList obsTargetList = new WritableList(realm, targetList, Integer.class);
System.out.println("before binding, obsTargetList: " + obsTargetList);

// bind
ctx.bindList(obsTargetList, obsModelList, null);
// obsTargetList is now in sync with obsModelList, i.e. [1,2]
System.out.println("after binding, obsTargetList: " + obsTargetList);

//  updateTarget
ctx.updateTargets();
// obsTargetList should still be [1,2] but is [1,2,1,2]
System.out.println("after updateTargets(), obsTargetList: " + obsTargetList);

--
Gruesse/Regards,

Peter Maas, Aachen
E-mail "cC5tYWFzQG1hZ21hc29mdC5kZQ==\n".decode("base64")