# Latest juce.Plugin demo hangs host on closing when UI opened

**URL:** <https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101>\
**Category:** Audio Plugins\
**Created:** [July 15, 2009, 12:34pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101 "2009-07-15T12:34:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Nkey](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/_nkey/32/399_2.png) [@\_Nkey](https://forum.juce.com/u/_Nkey)\
**Post date:** [July 15, 2009, 12:34pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/1 "2009-07-15T12:34:53Z")

</div>

Hello.

Download latest juce from subversion.  
Build demo plugin as AU.  
Open some host(Ableton, or juce demo host).  
Open plugin GUI in it.  
Press host’s close button.  
Result: host hangs for long time.

Thanks, Michail.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 15, 2009, 2:39pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/2 "2009-07-15T14:39:24Z")

</div>

No such problems here…

Try debugging it - should be easy to catch it and see what’s going on.

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [July 17, 2009, 1:35am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/3 "2009-07-17T01:35:27Z")

</div>

I have the same problem with Ableton Live 7.0. Live crashes consistently when I try to quit Live with my plugin enabled, and occasionally when I try to delete the instance of the plugin. I verified that it works with the Demo Plugin (or at least my renamed version of this plugin). Do you want a detailed crash report, or what would be useful to help you debug this?

I am working from the latest tip as of this afternoon.

Thanks,

Sean Costello

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 17, 2009, 8:42am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/4 "2009-07-17T08:42:36Z")

</div>

> [@](#):
>
> I have the same problem with Ableton Live 7.0. Live crashes consistently when I try to quit Live with my plugin enabled, and occasionally when I try to delete the instance of the plugin. I verified that it works with the Demo Plugin (or at least my renamed version of this plugin). Do you want a detailed crash report, or what would be useful to help you debug this?

If the demo plugin works, then the crash must be in your own code!

Guys, it doesn’t sound like either of you actually used the debugger before posting - the debugger is your friend, and will save you a lot of time and hassle…

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [July 17, 2009, 9:12am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/5 "2009-07-17T09:12:58Z")

</div>

> [@jules](#):
>
> [quote]I have the same problem with Ableton Live 7.0. Live crashes consistently when I try to quit Live with my plugin enabled, and occasionally when I try to delete the instance of the plugin. I verified that it works with the Demo Plugin (or at least my renamed version of this plugin). Do you want a detailed crash report, or what would be useful to help you debug this?

If the demo plugin works, then the crash must be in your own code!

Guys, it doesn’t sound like either of you actually used the debugger before posting - the debugger is your friend, and will save you a lot of time and hassle…[/quote]

I’m sorry - I meant to say that Live CRASHES with the Demo plugin, as described above. It doesn’t work properly. The edit button would have been my friend for my post. It was a long day.

Sean Costello

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 17, 2009, 9:48am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/6 "2009-07-17T09:48:01Z")

</div>

Ah, that makes more sense!

Well, I was testing it in Live 6 and it works just fine, but maybe something is different in Live 7. I guess I’ll have to get a copy and try it.

---

<div class="post-metadata">

**Author:** ![\_Nkey](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/_nkey/32/399_2.png) [@\_Nkey](https://forum.juce.com/u/_Nkey)\
**Post date:** [July 17, 2009, 9:53am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/7 "2009-07-17T09:53:38Z")

</div>

Got this:

Thread 0 Crashed:  
0 com.ableton.live 0x00109024 0x1000 + 1081380  
1 com.ableton.live 0x0023b0d4 0x1000 + 2334932  
2 com.ableton.live 0x000e3f95 0x1000 + 929685  
3 com.ableton.live 0x000e3fc6 0x1000 + 929734  
4 com.ableton.live 0x000e3fc6 0x1000 + 929734  
5 com.ableton.live 0x000e3fc6 0x1000 + 929734  
6 com.ableton.live 0x000e3fc6 0x1000 + 929734  
7 com.ableton.live 0x000e3fc6 0x1000 + 929734  
8 com.ableton.live 0x000e3fc6 0x1000 + 929734  
9 com.ableton.live 0x0011bf12 0x1000 + 1158930  
10 com.ableton.live 0x0040302e 0x1000 + 4202542  
11 com.ableton.live 0x003fe3a9 0x1000 + 4182953  
12 com.apple.HIToolbox 0x91c9a303 DispatchEventToHandlers(EventTargetRec\*, OpaqueEventRef\*, HandlerCallRec\*) + 1181  
13 com.apple.HIToolbox 0x91c9973d SendEventToEventTargetInternal(OpaqueEventRef\*, OpaqueEventTargetRef\*, HandlerCallRec\*) + 405  
14 com.apple.HIToolbox 0x91c995a2 SendEventToEventTargetWithOptions + 58  
15 com.apple.HIToolbox 0x91cc7f14 ToolboxEventDispatcherHandler(OpaqueEventHandlerCallRef\*, OpaqueEventRef\*, void\*) + 356  
16 com.apple.HIToolbox 0x91c9a6bc DispatchEventToHandlers(EventTargetRec\*, OpaqueEventRef\*, HandlerCallRec\*) + 2134  
17 com.apple.HIToolbox 0x91c9973d SendEventToEventTargetInternal(OpaqueEventRef\*, OpaqueEventTargetRef\*, HandlerCallRec\*) + 405  
18 com.apple.HIToolbox 0x91cb6092 SendEventToEventTarget + 52  
19 com.apple.AppKit 0x9029d93b \_DPSNextEvent + 2015  
20 com.apple.AppKit 0x9029cca0 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128  
21 com.discodsp. 0x15cf5b4b juce::MessageManager::runDispatchLoopUntil(int) + 363 (juce\_amalgamated.cpp:272547)  
22 com.discodsp. 0x15d21bac juce::MessageManager::doPlatformSpecificShutdown() + 196 (juce\_amalgamated.cpp:272578)  
23 com.discodsp. 0x15d21c73 juce::MessageManager::~MessageManager() + 103 (juce\_amalgamated.cpp:37445)  
24 com.discodsp. 0x15d2bd0f juce::shutdownJuce\_GUI() + 81 (juce\_amalgamated.cpp:16325)  
25 com.discodsp. 0x15e4d931 JuceAU::~JuceAU() + 419 (juce\_AU\_Wrapper.mm:156)  
26 com.discodsp. 0x15bad8e8 ComponentBase::ComponentEntryDispatch(ComponentParameters\*, ComponentBase\*) + 126 (ComponentBase.cpp:72)  
27 com.discodsp. 0x15ba8455 AUBase::ComponentEntryDispatch(ComponentParameters\*, AUBase\*) + 2437 (AUDispatch.cpp:400)  
28 com.discodsp. 0x15e5051c MusicDeviceBase::ComponentEntryDispatch(ComponentParameters\*, MusicDeviceBase\*) + 464 (MusicDeviceBase.cpp:247)  
29 com.discodsp. 0x15e4e49d ComponentEntryPoint::Dispatch(ComponentParameters\*, JuceAU\*) + 199 (ComponentBase.h:91)  
30 com.discodsp. 0x15e49a56 DiscoveryProEntry + 30 (juce\_AU\_Wrapper.mm:1352)  
31 …ple.CoreServices.CarbonCore 0x9538dded CallComponentDispatch + 29  
32 …ple.CoreServices.CarbonCore 0x9538eb2d CallComponentClose + 43  
33 …ple.CoreServices.CarbonCore 0x9538ea51 CloseComponentInternal(ComponentInstanceRecord\*) + 101  
34 …ple.CoreServices.CarbonCore 0x9538e9d2 CloseComponent + 46  
35 com.ableton.live 0x01340215 catch\_exception\_raise + 11366333  
36 com.ableton.live 0x010e04e3 catch\_exception\_raise + 8876683  
37 com.ableton.live 0x00516e83 0x1000 + 5332611  
38 com.ableton.live 0x0186b934 OMessageQueue::ProcessAndSubMessage() + 190  
39 com.ableton.live 0x00dc2901 catch\_exception\_raise + 5609129  
40 com.ableton.live 0x00513aba 0x1000 + 5319354  
41 com.ableton.live 0x001bfe0b 0x1000 + 1830411  
42 com.ableton.live 0x002c4bae 0x1000 + 2898862  
43 com.ableton.live 0x01611aa9 TIndexUpdateLocation::TIndexUpdateLocation(TIndexUpdateLocation const&) + 111873  
44 com.ableton.live 0x002e402d 0x1000 + 3026989  
45 com.ableton.live 0x002e1c41 0x1000 + 3017793  
46 com.ableton.live 0x01634bf6 TListable::~TListable() + 15608  
47 com.ableton.live 0x000345dd 0x1000 + 210397  
48 com.ableton.live 0x0019498c 0x1000 + 1653132  
49 com.ableton.live 0x000293a0 0x1000 + 164768  
50 com.ableton.live 0x001e083b 0x1000 + 1964091  
51 com.ableton.live 0x00119d2d 0x1000 + 1150253  
52 com.ableton.live 0x0017125c 0x1000 + 1507932  
53 com.ableton.live 0x00159636 0x1000 + 1410614  
54 com.ableton.live 0x0012026e 0x1000 + 1176174  
55 com.ableton.live 0x0030fa83 0x1000 + 3205763  
56 com.ableton.live 0x000a14ab 0x1000 + 656555  
57 com.ableton.live 0x003fe3a9 0x1000 + 4182953  
58 com.apple.HIToolbox 0x91c9a303 DispatchEventToHandlers(EventTargetRec\*, OpaqueEventRef\*, HandlerCallRec\*) + 1181  
59 com.apple.HIToolbox 0x91c9973d SendEventToEventTargetInternal(OpaqueEventRef\*, OpaqueEventTargetRef\*, HandlerCallRec\*) + 405  
60 com.apple.HIToolbox 0x91cb6092 SendEventToEventTarget + 52  
61 com.apple.HIToolbox 0x91cea31d SendHICommandEvent(unsigned long, HICommand const\*, unsigned long, unsigned long, unsigned char, OpaqueEventTargetRef\*, OpaqueEventTargetRef\*, OpaqueEventRef\*\*) + 411  
62 com.apple.HIToolbox 0x91d10b6f SendMenuCommandWithContextAndModifiers + 59  
63 com.apple.HIToolbox 0x91d10b2c SendMenuItemSelectedEvent + 134  
64 com.apple.HIToolbox 0x91d10a3e FinishMenuSelection(MenuData\*, MenuData\*, MenuResult\*, MenuResult\*, unsigned long, unsigned long, unsigned long, unsigned char) + 162  
65 com.apple.HIToolbox 0x91ced5cc MenuSelectCore(MenuData\*, Point, double, unsigned long, OpaqueMenuRef\*\*, unsigned short\*) + 640  
66 com.apple.HIToolbox 0x91d7c248 MenuSelect + 104  
67 com.apple.HIToolbox 0x91d7c1b8 HIMenuBar::HandleMouseEvent(OpaqueEventRef\*) + 92  
68 com.apple.HIToolbox 0x91c9a811 HIObject::EventHook(OpaqueEventHandlerCallRef\*, OpaqueEventRef\*, void\*) + 173  
69 com.apple.HIToolbox 0x91c9a303 DispatchEventToHandlers(EventTargetRec\*, OpaqueEventRef\*, HandlerCallRec\*) + 1181  
70 com.apple.HIToolbox 0x91c9973d SendEventToEventTargetInternal(OpaqueEventRef\*, OpaqueEventTargetRef\*, HandlerCallRec\*) + 405  
71 com.apple.HIToolbox 0x91cb6092 SendEventToEventTarget + 52  
72 com.apple.HIToolbox 0x91cc87c3 ToolboxEventDispatcherHandler(OpaqueEventHandlerCallRef\*, OpaqueEventRef\*, void\*) + 2579  
73 com.apple.HIToolbox 0x91c9a6bc DispatchEventToHandlers(EventTargetRec\*, OpaqueEventRef\*, HandlerCallRec\*) + 2134  
74 com.apple.HIToolbox 0x91c9973d SendEventToEventTargetInternal(OpaqueEventRef\*, OpaqueEventTargetRef\*, HandlerCallRec\*) + 405  
75 com.apple.HIToolbox 0x91cb6092 SendEventToEventTarget + 52  
76 com.apple.HIToolbox 0x91d22c60 ToolboxEventDispatcher + 86  
77 com.apple.HIToolbox 0x91d1f4ba RunApplicationEventLoop + 222  
78 com.ableton.live 0x000a2964 0x1000 + 661860  
79 com.ableton.live 0x00002ae6 0x1000 + 6886  
80 com.ableton.live 0x00002a0d 0x1000 + 6669

I’ll debug this moment tommorow.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 17, 2009, 10:20am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/8 "2009-07-17T10:20:54Z")

</div>

Thanks, I’ve just checked in a fix for it now.

---

<div class="post-metadata">

**Author:** ![\_Nkey](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/_nkey/32/399_2.png) [@\_Nkey](https://forum.juce.com/u/_Nkey)\
**Post date:** [July 17, 2009, 10:49am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/9 "2009-07-17T10:49:18Z")

</div>

Cool, thanks!

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [July 17, 2009, 5:36pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/10 "2009-07-17T17:36:56Z")

</div>

From my initial tests, that seems to have done the trick. Thanks!

I now have plugins built with code from the tip, that work in Carbon hosts (Live 7.0), Cocoa hosts (Logic, Garage Band), and on the PC.

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [July 18, 2009, 6:12pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/11 "2009-07-18T18:12:36Z")

</div>

I posted too soon, apparently. My AUs work great in Live now, but the VSTs crash Live when deleting the plugin, or closing Live. Here’s the crash log:

[code]Exception Type: EXC\_BAD\_ACCESS (SIGSEGV)  
Exception Codes: KERN\_INVALID\_ADDRESS at 0x00000000172196c0  
Crashed Thread: 0

Thread 0 Crashed:  
0 libobjc.A.dylib 0x9570a688 objc\_msgSend + 24  
1 com.apple.CoreFoundation 0x96c66595 CFRunLoopRunSpecific + 3141  
2 com.apple.CoreFoundation 0x96c66c78 CFRunLoopRunInMode + 88  
3 com.apple.HIToolbox 0x9234328c RunCurrentEventLoopInMode + 283  
4 com.apple.HIToolbox 0x92342fde ReceiveNextEventCommon + 175  
5 com.apple.HIToolbox 0x923a1b36 \_AcquireNextEvent + 58  
6 com.apple.HIToolbox 0x923a0293 RunApplicationEventLoop + 207  
7 com.ableton.live 0x000a2304 0x1000 + 660228  
8 com.ableton.live 0x00002486 0x1000 + 5254  
9 com.ableton.live 0x000023ad 0x1000 + 5037  
[/code]

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 19, 2009, 11:17am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/12 "2009-07-19T11:17:45Z")

</div>

Try the code I’ve just checked in - I’ve not tried it with this problem, but it might be related.

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [July 20, 2009, 8:39pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/13 "2009-07-20T20:39:15Z")

</div>

I just did a clean rebuild with rev 751, and the same problem exists. Demo Juce Plugin crashes in OS X 10.5.7, using Ableton Live Lite 7.0.something, when trying to delete the plugin. Same error message as listed above.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 21, 2009, 8:57am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/14 "2009-07-21T08:57:35Z")

</div>

I just tried it with Live 7 lite and can’t find any problems… Are you sure you’ve rebuilt everything and that it’s not loading an older version of the plugin?

---

<div class="post-metadata">

**Author:** ![Salvator](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Salvator](https://forum.juce.com/u/Salvator)\
**Post date:** [July 21, 2009, 9:45am UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/15 "2009-07-21T09:45:58Z")

</div>

Hello,

Just downloaded rev 752, did the build from the demo plugin,  
renamed .component to .vst, and putted that in my VST folder.

Then in live 7.0.16 :  
dragged in the jucedemoplugin, choosed “fermer set live” (that close in french) and crash :

Thread 0 Crashed:  
0 libobjc.A.dylib 0x96522688 objc\_msgSend + 24  
1 com.apple.CoreFoundation 0x9685c942 \_\_CFRunLoopDoObservers + 466  
2 com.apple.CoreFoundation 0x9685dc9c CFRunLoopRunSpecific + 844  
3 com.apple.CoreFoundation 0x9685ec78 CFRunLoopRunInMode + 88  
4 com.apple.HIToolbox 0x957a228c RunCurrentEventLoopInMode + 283  
5 com.apple.HIToolbox 0x957a1fde ReceiveNextEventCommon + 175  
6 com.apple.HIToolbox 0x95800b36 \_AcquireNextEvent + 58  
7 com.apple.HIToolbox 0x957ff293 RunApplicationEventLoop + 207  
8 com.ableton.live 0x0109366b ALetter::~ALetter() + 38291  
9 com.ableton.live 0x000020e2 0x1000 + 4322  
10 com.ableton.live 0x00002009 0x1000 + 4105

Hope this helps,

Salvator

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 21, 2009, 2:06pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/16 "2009-07-21T14:06:50Z")

</div>

Ok. I’m absolutely stumped by this one, I’m afraid.

I’ve tried a whole bunch of things, but can’t see what’s going on. The crash happens after the plugin has been completely unloaded, so it’s not actually any of my code that’s crashing.

At first I thought it must be because an event has been left in the message queue, which then gets delivered after the plugin has gone, and therefore crashes because the objects it refers to have been deleted, but I’ve tested this, and there aren’t any messages being left behind (I’ve just checked-in some new code that tweaks the messaging slightly to make sure of this)

The AU works perfectly, it’s just the VST that’s got this problem, and for me it also happens when you delete the plugin, as well as when you close the session.

But I’ve absolutely no ideas left… It’s impossible to debug because the plugin isn’t loaded when it happens, so it’s just a case of trial-and-error to figure out what Live is having a problem with… Help! Suggestions wanted!

---

<div class="post-metadata">

**Author:** ![Salvator](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Salvator](https://forum.juce.com/u/Salvator)\
**Post date:** [July 21, 2009, 4:30pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/17 "2009-07-21T16:30:59Z")

</div>

Hello,

It also crash the host “reaper”, though the crash log is slight different :

Thread 0 Crashed:  
0 libobjc.A.dylib 0x96522688 objc\_msgSend + 24  
1 com.apple.AppKit 0x92633ffa -[NSWindow \_cancelPerformSelectors] + 398  
2 com.apple.AppKit 0x9263269b -[NSWindow dealloc] + 1175  
3 com.apple.AppKit 0x926321ad \_NXFreeImageCache + 1010  
4 com.apple.AppKit 0x92631d3d -[NSCachedImageRep dealloc] + 216  
5 com.apple.AppKit 0x92631b0d -[NSImage \_freeRepresentation:] + 328  
6 com.apple.AppKit 0x92631914 -[NSImage dealloc] + 133  
7 com.cockos.reaper 0x002fc97d DeleteObject(void\*) + 131  
8 com.cockos.reaper 0x003c745a Main\_OnAppQuit() + 618

Does it bring something new and usefull ?

Salvator

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 21, 2009, 5:03pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/18 "2009-07-21T17:03:57Z")

</div>

Thanks, that’s maybe a bit of a hint that it might be window-related…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 21, 2009, 5:24pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/19 "2009-07-21T17:24:35Z")

</div>

Ok, I think I’ve got it… If I’m right, it’s because the message dispatch loop needs to run in between closing the window and deleting the plugin itself, which doesn’t happen if you just delete the plugin with its window open. This might be to let the cocoa windowing stuff clean up or something obscure…

It’s a one-liner, but I’d appreciate it if people could try this in various hosts to see if it works:

in VST\_Wrapper.mm:

[code]void detachComponentFromWindowRef (Component\* comp, void\* nsWindow)  
{  
const ScopedAutoReleasePool pool;

#if ADD\_CARBON\_BODGE  
EventHandlerRef ref = (EventHandlerRef) (void\*) (pointer\_sized\_int)  
comp-\>getComponentProperty (“carbonEventRef”, false, String::empty).getHexValue64();  
RemoveEventHandler (ref);  
#endif

```
NSWindow* hostWindow = (NSWindow*) nsWindow;
NSView* pluginView = (NSView*) comp->getWindowHandle();
NSWindow* pluginWindow = [pluginView window];

[hostWindow removeChildWindow: pluginWindow];
comp->removeFromDesktop();

[hostWindow release];

MessageManager::getInstance()->runDispatchLoopUntil (10);

```

}[/code]

---

<div class="post-metadata">

**Author:** ![Salvator](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Salvator](https://forum.juce.com/u/Salvator)\
**Post date:** [July 21, 2009, 6:33pm UTC](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101/20 "2009-07-21T18:33:17Z")

</div>

Seems evolving the good way as, in my setup, the crashes (‘on delete’ and ‘on quit’) are gone in Live 7 !

On reaper there is still a crash ‘on quit’ though :

Thread 0 Crashed:  
0 libobjc.A.dylib 0x96522688 objc\_msgSend + 24  
1 com.apple.AppKit 0x92633ffa -[NSWindow \_cancelPerformSelectors] + 398  
2 com.apple.AppKit 0x9263269b -[NSWindow dealloc] + 1175  
3 com.cockos.reaper 0x002f6f28 -[SWELL\_APP\_PREFIX\_modelesswindow dealloc] + 58  
4 com.apple.CoreFoundation 0x9686055a CFRelease + 90  
5 com.apple.CoreFoundation 0x967ef59d \_\_CFArrayReleaseValues + 221  
6 com.apple.CoreFoundation 0x96860708 _CFRelease + 216  
7 com.apple.Foundation 0x900df45f NSPopAutoreleasePool + 431  
8 com.apple.Foundation 0x900e9b32 +[NSAutoreleasePool releaseAllPools] + 50  
9 com.apple.AppKit 0x92782bdb -[NSApplication deallocHardCore:] + 505  
10 com.apple.AppKit 0x927818b1 -[NSApplication terminate:] + 742  
11 com.cockos.reaper 0x00017260 MacRequestQuit() + 48  
12 com.cockos.reaper 0x003c1cb8 MainProc(HWND_\*, unsigned int, unsigned long, long) + 1288

Thanks !

Salvator

[Next page](https://forum.juce.com/t/latest-juce-plugin-demo-hangs-host-on-closing-when-ui-opened/4101.md?page=2)
