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 register/unregister issues of WeakReferenceMessenger #4082

Merged
5 commits merged into from
Jul 5, 2021

Conversation

steinhilber
Copy link
Contributor

Fixes #4081

PR Type

What kind of change does this PR introduce?

Bugfix

What is the current behavior?

The attached message handlers of a WeakReferenceMessenger do not get called anymore correctly for all registered objects after unregistering one of them.

What is the new behavior?

The attached message handlers get called for all registered objects.

There was an issue with the enumerator of the ConditionalWeakTable. The linked list nodes were not iterated correctly when a key gets removed while enumerating. In this case the "Next"-property of the node was set to null and the while loop stopped immediately (without checking the remaining nodes).

As a fix the next node is now kept as a locale variable so that it does not get lost when removing the key.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Jun 21, 2021

Thanks steinhilber for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker, azchohfi and Kyaa-dost June 21, 2021 10:04
@net-foundation-cla
Copy link

net-foundation-cla bot commented Jun 21, 2021

CLA assistant check
All CLA requirements met.

@net-foundation-cla
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

❌ steinhilber sign now
You have signed the CLA already but the status is still pending? Let us recheck it.

@ghost ghost requested a review from Rosuavio June 21, 2021 10:04
@ghost ghost added the bug 🐛 An unexpected issue that highlights incorrect behavior label Jun 21, 2021
@michael-hawker michael-hawker added this to the 7.1 milestone Jun 22, 2021
Copy link
Member

@Sergio0694 Sergio0694 left a comment

Choose a reason for hiding this comment

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

Thanks for adding a new test method too!
Just left some very small notes, but looks good overall 🙂

Co-authored-by: Sergio Pedri <sergio0694@live.com>
@ghost
Copy link

ghost commented Jun 23, 2021

This PR has been marked as "needs attention 👋" and awaiting a response from the team.

Co-authored-by: Sergio Pedri <sergio0694@live.com>
}
Copy link
Member

Choose a reason for hiding this comment

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

@michael-hawker Just a note: this is the same issue you had raised as well while reviewing #3893: without some automated process to either fix the formatting or at least validate that the state is kept consistent, it's really really easy to reintroduce differences in whitespace formatting while making changes (especially because VS sometimes applies these changes automatically) and still end up with the same situation we had before. As in, the changes in #3893 aren't really that easily maintainable in the long term right now without still ending up with some inconsistencies here and there by accident 🤔

Copy link
Member

@Sergio0694 Sergio0694 left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks! 🙌

Copy link
Contributor

@Rosuavio Rosuavio left a comment

Choose a reason for hiding this comment

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

Looks good!

@ghost
Copy link

ghost commented Jul 5, 2021

Hello @RosarioPulella!

Because this pull request has the auto merge :zap: label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 1973504 into CommunityToolkit:main Jul 5, 2021
Sergio0694 added a commit to Sergio0694/WindowsCommunityToolkit that referenced this pull request Jul 14, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merge ⚡ bug 🐛 An unexpected issue that highlights incorrect behavior needs attention 👋
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MessageHandlers not called anymore by WeakReferenceMessenger after UnregisterAll
4 participants