mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-22 01:34:21 +00:00
MenuBarComponent: Avoid dereferencing dangling pointer when dismissing menus
This commit is contained in:
parent
4011c2e898
commit
ffee9b19de
1 changed files with 7 additions and 1 deletions
|
|
@ -241,10 +241,16 @@ void MenuBarComponent::showMenu (int index)
|
|||
|
||||
auto itemBounds = itemComponent->getBounds();
|
||||
|
||||
const auto callback = [ref = SafePointer<MenuBarComponent> (this), index] (int result)
|
||||
{
|
||||
if (ref != nullptr)
|
||||
ref->menuDismissed (index, result);
|
||||
};
|
||||
|
||||
m.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
|
||||
.withTargetScreenArea (localAreaToGlobal (itemBounds))
|
||||
.withMinimumWidth (itemBounds.getWidth()),
|
||||
[this, index] (int result) { menuDismissed (index, result); });
|
||||
callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue