mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-04 03:40:07 +00:00
fixed a small problem when mac plugins are opened and closed quickly by the host
This commit is contained in:
parent
19f99e6c5c
commit
56c2fcf071
6 changed files with 54 additions and 5 deletions
|
|
@ -268525,6 +268525,9 @@ using namespace JUCE_NAMESPACE;
|
|||
|
||||
#define JuceAppDelegate MakeObjCClassName(JuceAppDelegate)
|
||||
|
||||
static int numPendingMessages = 0;
|
||||
static bool flushingMessages = false;
|
||||
|
||||
@interface JuceAppDelegate : NSObject
|
||||
{
|
||||
@private
|
||||
|
|
@ -268552,6 +268555,8 @@ using namespace JUCE_NAMESPACE;
|
|||
[super init];
|
||||
|
||||
redirector = new AppDelegateRedirector();
|
||||
numPendingMessages = 0;
|
||||
flushingMessages = false;
|
||||
|
||||
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
|
|
@ -268618,11 +268623,13 @@ using namespace JUCE_NAMESPACE;
|
|||
|
||||
- (void) customEvent: (id) n
|
||||
{
|
||||
atomicDecrement (numPendingMessages);
|
||||
|
||||
NSData* data = (NSData*) n;
|
||||
void* message = 0;
|
||||
[data getBytes: &message length: sizeof (message)];
|
||||
|
||||
if (message != 0)
|
||||
if (message != 0 && ! flushingMessages)
|
||||
redirector->deliverMessage (message);
|
||||
|
||||
[data release];
|
||||
|
|
@ -268715,12 +268722,25 @@ void MessageManager::doPlatformSpecificShutdown()
|
|||
{
|
||||
[[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: juceAppDelegate];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: juceAppDelegate];
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
jassert (numPendingMessages == 0); // failed to get all the pending messages cleared before quitting..
|
||||
|
||||
[juceAppDelegate release];
|
||||
juceAppDelegate = 0;
|
||||
}
|
||||
|
||||
bool juce_postMessageToSystemQueue (void* message)
|
||||
{
|
||||
atomicIncrement (numPendingMessages);
|
||||
|
||||
[juceAppDelegate performSelectorOnMainThread: @selector (customEvent:)
|
||||
withObject: (id) [[NSData alloc] initWithBytes: &message
|
||||
length: (int) sizeof (message)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue