Skip to content

Commit e3df22a

Browse files
committed
NSViewComponentPeer: Fix use-after-free when closing windows with the keyboard
1 parent cac1ad8 commit e3df22a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,9 +2333,14 @@ static id getAccessibleChild (id self)
23332333
{
23342334
if (auto* owner = getOwner (self))
23352335
{
2336-
const ScopedValueSetter scope { owner->inPerformKeyEquivalent, true };
2337-
23382336
const auto ref = owner->safeComponent;
2337+
const auto prev = std::exchange (owner->inPerformKeyEquivalent, true);
2338+
2339+
const ScopeGuard scope { [&ref, owner, prev]
2340+
{
2341+
if (ref != nullptr)
2342+
owner->inPerformKeyEquivalent = prev;
2343+
} };
23392344

23402345
if (owner->sendEventToInputContextOrComponent (ev))
23412346
{

0 commit comments

Comments
 (0)