[PR #13839] Fix a subtle issue with PropertyChanged in ViewModels #29794

Closed
opened 2026-01-31 09:36:55 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/13839

State: closed
Merged: Yes


While debugging #13694, we discovered a very subtle bug we had accidentally introduced in a few places. ViewModelHelper defines a PropertyChanged event, backed by a _propertyChangedHandlers event. All opbservable properties in the viewmodels are supposed to run through that event. However, if you do WINRT_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 PropertyChanged method 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 override keyword.

Unblocks #13694.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/13839 **State:** closed **Merged:** Yes --- While debugging #13694, we discovered a very subtle bug we had accidentally introduced in a few places. `ViewModelHelper` defines a `PropertyChanged` event, backed by a `_propertyChangedHandlers` `event`. All opbservable properties in the viewmodels are supposed to run through that event. However, if you do `WINRT_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 `PropertyChanged` method 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 `override` keyword. Unblocks #13694.
claunia added the pull-request label 2026-01-31 09:36:55 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29794