Skip to content

Commit

Permalink
Fix Progress Ring crash when changing the color of a solid color brus…
Browse files Browse the repository at this point in the history
…h that was used for a now destructed progress ring's Foreground/Background color. (#5201)
  • Loading branch information
StephenLPeters committed Jun 16, 2021
1 parent b85ec04 commit 3d2d5a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dev/ProgressRing/ProgressRing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void ProgressRing::OnForegroundPropertyChanged(const winrt::DependencyObject&, c
{
if (const auto foreground = Foreground().try_as<winrt::SolidColorBrush>())
{
foreground.RegisterPropertyChangedCallback(winrt::SolidColorBrush::ColorProperty(), { this, &ProgressRing::OnForegroundColorPropertyChanged });
m_foregroundColorPropertyChangedRevoker = RegisterPropertyChanged(foreground, winrt::SolidColorBrush::ColorProperty(), { this, &ProgressRing::OnForegroundColorPropertyChanged });
}

OnForegroundColorPropertyChanged(nullptr, nullptr);
Expand Down Expand Up @@ -103,7 +103,7 @@ void ProgressRing::OnBackgroundPropertyChanged(const winrt::DependencyObject&, c
{
if (const auto background = Background().try_as<winrt::SolidColorBrush>())
{
background.RegisterPropertyChangedCallback(winrt::SolidColorBrush::ColorProperty(), { this, &ProgressRing::OnBackgroundColorPropertyChanged });
m_backgroundColorPropertyChangedRevoker = RegisterPropertyChanged(background, winrt::SolidColorBrush::ColorProperty(), { this, &ProgressRing::OnBackgroundColorPropertyChanged });
}

OnBackgroundColorPropertyChanged(nullptr, nullptr);
Expand Down
3 changes: 3 additions & 0 deletions dev/ProgressRing/ProgressRing.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class ProgressRing :
tracker_ref<winrt::Grid> m_layoutRoot{ this };
tracker_ref<winrt::AnimatedVisualPlayer> m_player{ this };

PropertyChanged_revoker m_foregroundColorPropertyChangedRevoker{};
PropertyChanged_revoker m_backgroundColorPropertyChangedRevoker{};

double m_oldValue{ 0 };
bool m_rangeBasePropertyUpdating{ false };
};

0 comments on commit 3d2d5a8

Please sign in to comment.