From cfda532c9faa083f0f7bd14f2fbbb533c6cc6599 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 14 Oct 2021 14:04:19 +0100 Subject: [PATCH] iOS Windowing: Avoid crashing when displaying a message box from a background thread --- modules/juce_gui_basics/native/juce_ios_Windowing.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/native/juce_ios_Windowing.mm b/modules/juce_gui_basics/native/juce_ios_Windowing.mm index 41503d2a7b..574947484f 100644 --- a/modules/juce_gui_basics/native/juce_ios_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_ios_Windowing.mm @@ -523,7 +523,13 @@ static int showDialog (const MessageBoxOptions& options, } #endif - new iOSMessageBox (options, AlertWindowMappings::getWrappedCallback (callbackIn, mapFn)); + const auto showBox = [options, callbackIn, mapFn] { new iOSMessageBox (options, AlertWindowMappings::getWrappedCallback (callbackIn, mapFn)); }; + + if (MessageManager::getInstance()->isThisTheMessageThread()) + showBox(); + else + MessageManager::callAsync (showBox); + return 0; }