From 192cf670621aba882beea4bfd2706ece603644f5 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 17 Jul 2009 10:20:07 +0000 Subject: [PATCH] small tweak to avoid lock-ups when closing audio plugins in some hosts. --- .../platform_specific_code/juce_mac_MessageManager.mm | 9 ++++----- juce_amalgamated.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/build/macosx/platform_specific_code/juce_mac_MessageManager.mm b/build/macosx/platform_specific_code/juce_mac_MessageManager.mm index bda0adef73..b6dc7f475a 100644 --- a/build/macosx/platform_specific_code/juce_mac_MessageManager.mm +++ b/build/macosx/platform_specific_code/juce_mac_MessageManager.mm @@ -403,11 +403,10 @@ void MessageManager::doPlatformSpecificShutdown() // Annoyingly, cancelPerformSelectorsWithTarget can't actually cancel the messages // sent by performSelectorOnMainThread, so need to manually flush these before quitting.. - for (int i = 100; --i >= 0 && numPendingMessages > 0;) - { - flushingMessages = true; - getInstance()->runDispatchLoopUntil (10); - } + flushingMessages = true; + if (JUCEApplication::getInstance() != 0) // (must avoid blocking here when running as a plugin) + for (int i = 100; --i >= 0 && numPendingMessages > 0;) + getInstance()->runDispatchLoopUntil (10); [juceAppDelegate release]; juceAppDelegate = 0; diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index a7e38f1cdd..098b84fcf1 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -272543,11 +272543,10 @@ void MessageManager::doPlatformSpecificShutdown() // Annoyingly, cancelPerformSelectorsWithTarget can't actually cancel the messages // sent by performSelectorOnMainThread, so need to manually flush these before quitting.. - for (int i = 100; --i >= 0 && numPendingMessages > 0;) - { - flushingMessages = true; - getInstance()->runDispatchLoopUntil (10); - } + flushingMessages = true; + if (JUCEApplication::getInstance() != 0) // (must avoid blocking here when running as a plugin) + for (int i = 100; --i >= 0 && numPendingMessages > 0;) + getInstance()->runDispatchLoopUntil (10); [juceAppDelegate release]; juceAppDelegate = 0;