From 9bddeb9324ba119b2f6c0eaff786ec3c7192b4f7 Mon Sep 17 00:00:00 2001 From: Oliver James Date: Thu, 10 Oct 2024 15:42:24 +0100 Subject: [PATCH] MPEKeyboardComponent: Catch potential 'use after free' when cleaning up --- modules/juce_audio_utils/gui/juce_MPEKeyboardComponent.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_utils/gui/juce_MPEKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MPEKeyboardComponent.cpp index 0685c4d564..104a27e432 100644 --- a/modules/juce_audio_utils/gui/juce_MPEKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MPEKeyboardComponent.cpp @@ -507,7 +507,11 @@ void MPEKeyboardComponent::noteReleased (MPENote finishedNote) void MPEKeyboardComponent::zoneLayoutChanged() { - MessageManager::callAsync ([this] { updateZoneLayout(); }); + MessageManager::callAsync ([ref = SafePointer { this }] + { + if (ref != nullptr) + ref->updateZoneLayout(); + }); } } // namespace juce