From 4deee6976b4268f74b5d7f4041b2d62508aa8a56 Mon Sep 17 00:00:00 2001 From: attila Date: Mon, 3 Mar 2025 19:01:22 +0100 Subject: [PATCH] AU Client: Fix calling makeFirstResponder for nil window in Ableton Live When pressing the Escape key the call to hostView keyDown: closes the plugin window and the subsequent [hostView window] returns nil. --- .../juce_audio_plugin_client_AU_1.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm index becdbe1f1d..1f3a919380 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm @@ -1749,11 +1749,13 @@ public: auto* view = (NSView*) getWindowHandle(); auto* hostView = [view superview]; - auto* hostWindow = [hostView window]; - [hostWindow makeFirstResponder: hostView]; + [[hostView window] makeFirstResponder: hostView]; [hostView keyDown: currentEvent]; - [hostWindow makeFirstResponder: view]; + + if ((hostView = [view superview])) + if (auto* hostWindow = [hostView window]) + [hostWindow makeFirstResponder: view]; } } }