Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete changes at end of change sequence in ChangeRecorder #54

Merged
merged 3 commits into from
Jan 9, 2023

Conversation

JanWittler
Copy link
Contributor

This PR changes how delete changes are added to the change sequence recorded by the ChangeRecorder.
After recording finishes, the change recorder adds delete changes for every element implicitly deleted in the change sequence (i.e. for elements removed from their containment but not reinserted somewhere again). When inserting a delete change into the change sequence, any change after the delete change must not reference the deleted object anymore (as in theory the deleted object does not exist anymore at this point).

In the current behavior, the recorder adds the delete changes directly after the element is removed from its containment. However, this positioning does not guarantee that the element is never again referenced in changes after its delete change. As an example, a non-containment reference to the affected element might be unset after the element is removed from containment. While this would be easy to detect, since we also remove contained elements (see #48) such reference-after-delete issues might also occur more disguised when not the affected element itself but one of its descendants is referenced.

As such, this PR changes the behavior of the change recorder to append delete changes at the end of a change sequence. While identifying the earliest position in the sequence to insert the delete change would be possible, I opted for this easier solution simply as I didn't see any benefit of having the delete change as early as possible.
Additionally, this PR fixes the rare problem that an element and one of its descendants are both marked for deletion (when they are both removed from their containment), resulting in a duplicate delete change for the descendant (once from itself, once from its ancestor).

@JanWittler JanWittler added the enhancement New feature or request label Dec 27, 2022
@JanWittler JanWittler marked this pull request as ready for review December 27, 2022 13:50
@JanWittler JanWittler requested a review from TomWerm as a code owner December 27, 2022 13:50
@JanWittler JanWittler merged commit 75047c4 into main Jan 9, 2023
@JanWittler JanWittler deleted the fix-insert-delete-change branch January 9, 2023 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants