-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Fix a subtle issue with PropertyChanged in ViewModels #13839
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
Conversation
|
@carlos-zamora you will need to propagate some of these changes to the new ColorScheme page! |
|
I converted this to a draft so that it would not merge without a description |
| Editor::ColorTableEntry ColorEntryAt(uint32_t index); | ||
|
|
||
| WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler); | ||
| // DON'T YOU DARE ADD A `WINRT_CALLBACK(PropertyChanged` TO A CLASS DERIVED FROM ViewModelHelper. Do this instead: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This should be "why" and not "what".)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this merges, I'll merge it into #13269 and update that PR accordingly
|
@msftbot merge this in 2 minutes |
|
Hello @zadjii-msft! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
While debugging #13694, we discovered a very subtle bug we had accidentally introduced in a few places.
ViewModelHelperdefines aPropertyChangedevent, backed by a_propertyChangedHandlersevent. All opbservable properties in the viewmodels are supposed to run through that event. However, if you doWINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler)in a derived class, it'll override that original method with the new one. XAML will subscribe to the second one, which is backed by_PropertyChangedHandlers, but the properties will still raise notifications on the callbacks registered to_propertyChangedHandlers.This change makes it more explicit in these derived classes, that the
PropertyChangedmethod exposed by these classes is indeed the one that's implemented in the base class.This is a bit of a footgun, for sure. AuditMode would have apparently caught this, as we'd be overriding a method without using the
overridekeyword.Unblocks #13694.