From 46a4dc95a1e411f05856076539dc472883740e21 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 28 Sep 2021 16:06:04 +0100 Subject: [PATCH] Accessibility: Fix potential infinite recursive component keyboard focus loop --- .../juce_gui_basics/components/juce_Component.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index cf34a48777..00211b13b4 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -2687,13 +2687,17 @@ void Component::internalKeyboardFocusGain (FocusChangeType cause, { focusGained (cause); - if (safePointer != nullptr) - { + if (safePointer == nullptr) + return; + + if (hasKeyboardFocus (false)) if (auto* handler = getAccessibilityHandler()) handler->grabFocus(); - internalChildKeyboardFocusChange (cause, safePointer); - } + if (safePointer == nullptr) + return; + + internalChildKeyboardFocusChange (cause, safePointer); } void Component::internalKeyboardFocusLoss (FocusChangeType cause)