diff --git a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm index 55bfb74d8e..1aaf0ef8a6 100644 --- a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm +++ b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm @@ -1182,24 +1182,19 @@ public: private: void deleteUI() { - PopupMenu::dismissAllActiveMenus(); - - // there's some kind of component currently modal, but the host - // is trying to delete our plugin.. - jassert (Component::getCurrentlyModalComponent() == 0); + if (windowComp != 0) + { + PopupMenu::dismissAllActiveMenus(); - if (windowComp != 0 && windowComp->getChildComponent(0) != 0) - juceFilter->editorBeingDeleted ((AudioProcessorEditor*) windowComp->getChildComponent(0)); + // there's some kind of component currently modal, but the host + // is trying to delete our plugin.. + jassert (Component::getCurrentlyModalComponent() == 0); - deleteAndZero (windowComp); + if (windowComp != 0 && windowComp->getChildComponent(0) != 0) + juceFilter->editorBeingDeleted ((AudioProcessorEditor*) windowComp->getChildComponent(0)); - // The event loop needs to be run between closing the window and deleting the plugin, - // presumably to let the cocoa objects get tidied up. Leaving out this line causes crashes - // in Reaper when you delete the plugin with its window open. - // (Doing it this way rather than using a single longer timout means that we can guarantee - // how many messages will be dispatched, which seems to be vital in Reaper) - for (int i = 20; --i >= 0;) - MessageManager::getInstance()->runDispatchLoopUntil (1); + deleteAndZero (windowComp); + } } //============================================================================== diff --git a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm index bd94788c8d..05163647c5 100644 --- a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm +++ b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm @@ -29,13 +29,12 @@ #if JucePlugin_Build_VST #include - -#define ADD_CARBON_BODGE 1 // see note below.. - #include #include "../juce_PluginHeaders.h" +#define ADD_CARBON_BODGE 1 // see note below.. + //============================================================================== BEGIN_JUCE_NAMESPACE diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 14d5f31993..0a0151fe62 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -257323,7 +257323,7 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component, window = [[JuceNSWindow alloc] initWithContentRect: r styleMask: style backing: NSBackingStoreBuffered - defer: YES ]; + defer: YES]; [((JuceNSWindow*) window) setOwner: this]; [window orderOut: nil]; @@ -257337,7 +257337,12 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component, [window setContentView: view]; [window setAutodisplay: YES]; [window setAcceptsMouseMovedEvents: YES]; + + // We'll both retain and also release this on closing because plugin hosts can unexpectedly + // close the window for us, and also tend to get cause trouble if setReleasedWhenClosed is NO. [window setReleasedWhenClosed: YES]; + [window retain]; + [window setExcludedFromWindowsMenu: (windowStyleFlags & windowIsTemporary) != 0]; [window setIgnoresMouseEvents: (windowStyleFlags & windowIgnoresMouseClicks) != 0]; } @@ -257355,6 +257360,7 @@ NSViewComponentPeer::~NSViewComponentPeer() { [((JuceNSWindow*) window) setOwner: 0]; [window close]; + [window release]; } } diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 1596aa1fba..ef4b81a458 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -803,7 +803,7 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component, window = [[JuceNSWindow alloc] initWithContentRect: r styleMask: style backing: NSBackingStoreBuffered - defer: YES ]; + defer: YES]; [((JuceNSWindow*) window) setOwner: this]; [window orderOut: nil]; @@ -817,7 +817,12 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component, [window setContentView: view]; [window setAutodisplay: YES]; [window setAcceptsMouseMovedEvents: YES]; + + // We'll both retain and also release this on closing because plugin hosts can unexpectedly + // close the window for us, and also tend to get cause trouble if setReleasedWhenClosed is NO. [window setReleasedWhenClosed: YES]; + [window retain]; + [window setExcludedFromWindowsMenu: (windowStyleFlags & windowIsTemporary) != 0]; [window setIgnoresMouseEvents: (windowStyleFlags & windowIgnoresMouseClicks) != 0]; } @@ -835,6 +840,7 @@ NSViewComponentPeer::~NSViewComponentPeer() { [((JuceNSWindow*) window) setOwner: 0]; [window close]; + [window release]; } }