1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-17 00:44:19 +00:00

NSViewComponentPeer: Fix use-after-free when closing windows with the keyboard

This commit is contained in:
reuk 2025-04-01 11:46:51 +01:00
parent cac1ad8c1e
commit e3df22a4ea
No known key found for this signature in database

View file

@ -2333,9 +2333,14 @@ struct JuceNSViewClass final : public NSViewComponentPeerWrapper<ObjCClass<NSVie
{
if (auto* owner = getOwner (self))
{
const ScopedValueSetter scope { owner->inPerformKeyEquivalent, true };
const auto ref = owner->safeComponent;
const auto prev = std::exchange (owner->inPerformKeyEquivalent, true);
const ScopeGuard scope { [&ref, owner, prev]
{
if (ref != nullptr)
owner->inPerformKeyEquivalent = prev;
} };
if (owner->sendEventToInputContextOrComponent (ev))
{