Skip to content

Commit

Permalink
RadioMenuFlyoutItem destructor fix (#5033)
Browse files Browse the repository at this point in the history
  • Loading branch information
RBrid authored May 18, 2021
1 parent f56157d commit 1d184c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dev/RadioMenuFlyoutItem/RadioMenuFlyoutItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ RadioMenuFlyoutItem::RadioMenuFlyoutItem()
RadioMenuFlyoutItem::~RadioMenuFlyoutItem()
{
// If this is the checked item, remove it from the lookup.
if (IsChecked())
if (m_isChecked)
{
SharedHelpers::EraseIfExists(*s_selectionMap, GroupName());
SharedHelpers::EraseIfExists(*s_selectionMap, m_groupName);
}
}

Expand All @@ -46,6 +46,11 @@ void RadioMenuFlyoutItem::OnPropertyChanged(const winrt::DependencyPropertyChang
m_isSafeUncheck = false;
UpdateCheckedItemInGroup();
}
m_isChecked = IsChecked();
}
else if (property == s_GroupNameProperty)
{
m_groupName = GroupName();
}
}

Expand Down
4 changes: 4 additions & 0 deletions dev/RadioMenuFlyoutItem/RadioMenuFlyoutItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class RadioMenuFlyoutItem :

void UpdateCheckedItemInGroup();

// Copies of IsChecked & GroupName to avoid using those dependency properties in the ~RadioMenuFlyoutItem() destructor which would lead to crashes.
bool m_isChecked{ false };
winrt::hstring m_groupName{ L"" };

bool m_isSafeUncheck{ false };

PropertyChanged_revoker m_InternalIsCheckedChangedRevoker{};
Expand Down

0 comments on commit 1d184c4

Please sign in to comment.