Fix MappedBackedList handling of wasUpdated changes#87
Fix MappedBackedList handling of wasUpdated changes#87LoayGhreeb wants to merge 3 commits intotobiasdiez:mainfrom
MappedBackedList handling of wasUpdated changes#87Conversation
|
Thanks, could you please also add a test verifying that this is indeed fixed (and will not be reintroduced in the future). |
Done in |
|
It would be great if you could merge this and release a new version (olly is currently on holidays and I don't have admin rights on the namespace at sonatype so we cannot publish it under jabref namespace) Edit// For releasing you can take a look at the afterburner gradle https://github.com/JabRef/afterburner.fx/blob/main/build.gradle |
|
In some cases, I don't want to create a new object on update because I already have bindings that reflect the updates in the mapped object. How about introducing a new method: The changes to If you agree with this, should I do this in a separate PR? Edit: The method should be like this, assuming the |
|
I thought a bit more about this, but don't really have time right now to deep-dive into it. So please excuse any mistakes in the following and please do point them out.
So this is actually a bug in Or is there any other use case for calling |
|
@LoayGhreeb You can now open this PR against https://github.com/JabRef/EasyBind I have setup the publishing |
Initially, I thought the issue was that The actual issue is that Also, if the list has a comparator and an update change is fired, it resorts the list without considering the new object. Therefore, it might be better to create a PR for JavaFX because, as you mentioned, using
In the case of JabRef, we don't need to create a new object on change, so I suggested adding a new method: #87 (comment). If we add this method, JabRef will work fine. The issue should be reported to JavaFX for cases where a new object is mapped on update. |
|
I see that I tried to fix the I think From the
|
This PR addresses an issue related to
EasyBind#mapBacked. The problem arises when using aSortedListwith elements that are mapped usingEasyBind#mapBacked. Specifically, updates to elements in the list do not propagate to theSortedList.Minimal Example:
Output:
Expected Output:
The issue is due to the
SortedList#sourceChangedmethod in JavaFX. If there is no custom comparator,SortedList#updateUnsortedwill handle the updates, but it does not handle thewasUpdatedchange. This results in theSortedListnot updating when an element's change type iswasUpdated.Reference to the code:
SortedList#sourceChanged
SortedList#updateUnsorted
The fix involves using
nextSet, which is equivalent to callingnextRemove()followed bynextAdd(). This ensures that updates to elements are correctly propagated through to theSortedList.