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

NSViewComponentPeer: Attempt to avoid reentrant calls to makeKeyWindow

AUv2 plugins on Arm that are hosted out-of-process (e.g. in Logic 10.7)
can sometimes crash due to endlessly recursing through becomeKeyWindow.
This tends to happen when displaying a secondary window in a plugin,
e.g. an AlertWindow, then clicking on a secondary app, then clicking
back on the AlertWindow.

To avoid this case, we check that the peer isn't already key before
calling makeKeyWindow.

Unfortunately, we can't use isKeyWindow to avoid the recursion because
this may not return true until after becomeKeyWindow has returned.
This commit is contained in:
reuk 2023-02-06 19:36:28 +00:00
parent f5aa881b6f
commit 408f6030e6
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -558,7 +558,7 @@ public:
{
++insideToFrontCall;
if (makeActiveWindow)
if (makeActiveWindow && ! inBecomeKeyWindow)
[window makeKeyAndOrderFront: nil];
else
[window orderFront: nil];
@ -1541,7 +1541,9 @@ public:
{
if (window != nil)
{
[window makeKeyWindow];
if (! inBecomeKeyWindow)
[window makeKeyWindow];
[window makeFirstResponder: view];
viewFocusGain();
@ -1622,7 +1624,7 @@ public:
bool isFirstLiveResize = false, viewCannotHandleEvent = false;
bool isStretchingTop = false, isStretchingLeft = false, isStretchingBottom = false, isStretchingRight = false;
bool windowRepresentsFile = false;
bool isAlwaysOnTop = false, wasAlwaysOnTop = false;
bool isAlwaysOnTop = false, wasAlwaysOnTop = false, inBecomeKeyWindow = false;
String stringBeingComposed;
int startOfMarkedTextInTextInputTarget = 0;
@ -2453,6 +2455,10 @@ struct JuceNSWindowClass : public NSViewComponentPeerWrapper<ObjCClass<NSWindo
if (auto* owner = getOwner (self))
{
jassert (! owner->inBecomeKeyWindow);
const ScopedValueSetter scope { owner->inBecomeKeyWindow, true };
if (owner->canBecomeKeyWindow())
{
owner->becomeKeyWindow();