1
0
Fork 0
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:
reuk 2021-11-02 10:13:20 +00:00
parent 4011c2e898
commit ffee9b19de
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -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);
}
}
}