Skip to content

Commit

Permalink
Prevent excessive disposing of brushes (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
dongle-the-gadget authored Jan 7, 2025
1 parent d489d96 commit ead4723
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions NanaBox/ProgressRing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ namespace winrt::NanaBox::implementation
auto progressRing = d.as<NanaBox::ProgressRing>();
auto progressRingImpl = winrt::get_self<NanaBox::implementation::ProgressRing>(progressRing);

auto oldBrush = progressRingImpl->m_shape.StrokeBrush();
auto newBrush = progressRingImpl->m_compositor.CreateColorBrush(args.NewValue().as<Windows::UI::Xaml::Media::SolidColorBrush>().Color());
progressRingImpl->m_shape.StrokeBrush(newBrush);
auto brush = progressRingImpl->m_shape.StrokeBrush();

if (oldBrush)
if (brush)
{
oldBrush.Close();
brush.as<Windows::UI::Composition::CompositionColorBrush>().Color(args.NewValue().as<Windows::UI::Xaml::Media::SolidColorBrush>().Color());
}
}

Expand Down

0 comments on commit ead4723

Please sign in to comment.