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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13839
Author: @zadjii-msft
Created: 8/24/2022
Status: Merged
Merged: 8/25/2022
Merged by: @undefined

Base: mainHead: dev/migrie/b/subtle-propertychanged-on-main


📝 Commits (1)

📊 Changes

6 files changed (+19 additions, -14 deletions)

View changed files

📝 src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h (+6 -5)
📝 src/cascadia/TerminalSettingsEditor/ColorSchemesPageViewModel.cpp (+3 -3)
📝 src/cascadia/TerminalSettingsEditor/ColorSchemesPageViewModel.h (+4 -3)
📝 src/cascadia/TerminalSettingsEditor/GlobalAppearanceViewModel.h (+3 -1)
📝 src/cascadia/TerminalSettingsEditor/InteractionViewModel.h (+2 -1)
📝 src/cascadia/TerminalSettingsEditor/ViewModelHelpers.h (+1 -1)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/13839 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 8/24/2022 **Status:** ✅ Merged **Merged:** 8/25/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/migrie/b/subtle-propertychanged-on-main` --- ### 📝 Commits (1) - [`af49905`](https://github.com/microsoft/terminal/commit/af499054aecd72915a2d3bb7ce846a11edca42e5) wow this is subtle ### 📊 Changes **6 files changed** (+19 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h` (+6 -5) 📝 `src/cascadia/TerminalSettingsEditor/ColorSchemesPageViewModel.cpp` (+3 -3) 📝 `src/cascadia/TerminalSettingsEditor/ColorSchemesPageViewModel.h` (+4 -3) 📝 `src/cascadia/TerminalSettingsEditor/GlobalAppearanceViewModel.h` (+3 -1) 📝 `src/cascadia/TerminalSettingsEditor/InteractionViewModel.h` (+2 -1) 📝 `src/cascadia/TerminalSettingsEditor/ViewModelHelpers.h` (+1 -1) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:36:54 +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#29789