Skip to content

Commit 3d2d5a8

Browse files
Fix Progress Ring crash when changing the color of a solid color brush that was used for a now destructed progress ring's Foreground/Background color. (#5201)
1 parent b85ec04 commit 3d2d5a8

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

dev/ProgressRing/ProgressRing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void ProgressRing::OnForegroundPropertyChanged(const winrt::DependencyObject&, c
6969
{
7070
if (const auto foreground = Foreground().try_as<winrt::SolidColorBrush>())
7171
{
72-
foreground.RegisterPropertyChangedCallback(winrt::SolidColorBrush::ColorProperty(), { this, &ProgressRing::OnForegroundColorPropertyChanged });
72+
m_foregroundColorPropertyChangedRevoker = RegisterPropertyChanged(foreground, winrt::SolidColorBrush::ColorProperty(), { this, &ProgressRing::OnForegroundColorPropertyChanged });
7373
}
7474

7575
OnForegroundColorPropertyChanged(nullptr, nullptr);
@@ -103,7 +103,7 @@ void ProgressRing::OnBackgroundPropertyChanged(const winrt::DependencyObject&, c
103103
{
104104
if (const auto background = Background().try_as<winrt::SolidColorBrush>())
105105
{
106-
background.RegisterPropertyChangedCallback(winrt::SolidColorBrush::ColorProperty(), { this, &ProgressRing::OnBackgroundColorPropertyChanged });
106+
m_backgroundColorPropertyChangedRevoker = RegisterPropertyChanged(background, winrt::SolidColorBrush::ColorProperty(), { this, &ProgressRing::OnBackgroundColorPropertyChanged });
107107
}
108108

109109
OnBackgroundColorPropertyChanged(nullptr, nullptr);

dev/ProgressRing/ProgressRing.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class ProgressRing :
5555
tracker_ref<winrt::Grid> m_layoutRoot{ this };
5656
tracker_ref<winrt::AnimatedVisualPlayer> m_player{ this };
5757

58+
PropertyChanged_revoker m_foregroundColorPropertyChangedRevoker{};
59+
PropertyChanged_revoker m_backgroundColorPropertyChangedRevoker{};
60+
5861
double m_oldValue{ 0 };
5962
bool m_rangeBasePropertyUpdating{ false };
6063
};

0 commit comments

Comments
 (0)