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

Fix batch updates to allow cleared values to be re-set #5686

Merged
merged 16 commits into from
Mar 28, 2021

Conversation

grokys
Copy link
Member

@grokys grokys commented Mar 19, 2021

What does the pull request do?

@MarchingCube reported a problem introduced by #5070 whereby if a property was cleared during a batch update and then re-set in the PropertyChanged notification raised on ending the batch update, an exception would be thrown.

This was caused by our usage of sentinel values to indicate that a local value property entry needs to be removed at the end of a batch update. The fixes are:

  • If a new local value is written to the store in the course of ending the batch update, don't update the sentinel value as the value will subsequently be lost. Instead create a new local value
  • Allow adding a binding to a cleared property while ending a batch update
  • When a binding is added during the end of a batch update, _batchUpdate will be non-null but newly added bindings shouldn't have BeginBatchUpdate called on them because no EndBatchUpdate will arrive (as we've already called them)

Update: it seems #5697 was also caused by batch updating. The ValueStore fix is:

  • Fix bindings being disposed during batch update

But it seems that batch updates also exposed some problems with transitions. Fix those:

  • Handle changing a Transitions collections to new collection which contains some of the same elements
  • Handle changing transitions during batch update: transition state may not have been initialized by the time the change notification is received for the property which has a transition

Fixes #5697

grokys added 4 commits March 19, 2021 12:55
During a batch update sentinel values are written to the value store to indicate that the value needs to be removed at the end of the update. If a new value is written to the store in the course of ending the batch update, don't update this sentinel value as the value will subsequently be lost.
And a bit of a sanity check to the previous one.
- Allow adding a binding to a cleared property while ending a batch update. Need to check that the existing value isn't a remove sentinel here, otherwise the binding will be lost.
- When a binding is added during the end of a batch update, `_batchUpdate` will be non-null but newly added bindings shouldn't have `BeginBatchUpdate` called on them because no `EndBatchUpdate` will arrive (as we've already called them)
- Add sanity checks to the unit test to make sure that correct notifications are raised
@grokys grokys requested a review from MarchingCube March 19, 2021 13:33
@MarchingCube
Copy link
Collaborator

I've asked @Michron to check if it fixes problems on our side.

Copy link
Collaborator

@MarchingCube MarchingCube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix confirmed.

grokys added 8 commits March 25, 2021 14:18
To test completing/disposing bindings during and while ending batch updates.
Fixes tests in previous commit which test scenarios where bindings are completed/disposed during and when ending batch updates.
Handle changing a `Transitions` collections to new collection which contains some of the same elements.

Added a comment explaining why we add new transitions before replacing old transitions; was explained in the commit message for 0694b22.
Fixes failing test from previous commit.
@grokys
Copy link
Member Author

grokys commented Mar 25, 2021

@MarchingCube should now also fix #5697.

@MarchingCube
Copy link
Collaborator

Tested again, works fine and fixes both issues 👍

@maxkatz6 maxkatz6 merged commit 5f57ced into master Mar 28, 2021
@maxkatz6 maxkatz6 deleted the fixes/batchupdate-set-cleared-value-end-update branch March 28, 2021 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[master branch] Theme switching in Control Catalog is broken
4 participants