From 64896eefcdd99c8657ccf9ac2245582c86a47414 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 12 May 2021 16:44:38 +0100 Subject: [PATCH] Accessibility: Fixed a potential crash when re-using custom ListBox components --- modules/juce_gui_basics/widgets/juce_ListBox.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index dba7ca1712..7cdb4d738d 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -79,12 +79,7 @@ public: row = newRow; if (selectionHasChanged) - { isSelected = nowSelected; - - if (auto* handler = getAccessibilityHandler()) - isSelected ? handler->grabFocus() : handler->giveAwayFocus(); - } } if (auto* m = owner.getModel()) @@ -102,6 +97,10 @@ public: invalidateAccessibilityHandler(); } } + + if (selectionHasChanged) + if (auto* handler = getAccessibilityHandler()) + isSelected ? handler->grabFocus() : handler->giveAwayFocus(); } void performSelection (const MouseEvent& e, bool isMouseUp)