PopupMenu causes crash

I’m using a PopupMenu in my AU plugin. If I open the PopupMenu and close the GUI window for the plugin, the PopupMenu stays - and when clicking inside it, it causes the AU Host to crash. I tested this with Logic 7.2

I notice some host do not allow to close the application/window before the PopupMenu is clicked - but Logic is one of the hosts that does allow this.

Is there a way to get around this?


Martin Saleteg

Slightly tricky - if you call showMenu() in a method call of a component, and that component gets deleted before showMenu() returns, then anything you do afterwards might be using a dangling pointer. Try using a ComponentDeletionWatcher to double-check the state of your component after the showmenu() method, and if it’s been deleted, do a return pretty sharpish.

TBH I don’t think there’s actually any other way of avoiding the problem…

Thanks, that did the trick.

The menu is still left dangling however, which looks pretty ugly. Any way to get rid of that besides clicking it?


I guess it’s dangling because there’s no way juce can get any hint from logic that the focus has changed. I’ll have a look and see what I can do. Probably a useful addition would be a dismissAllMenus() type function that you could call if your UI is deleted. I’ll throw that into the build soon.


I would very much appreciate that function.


Ok, it’s there on the tip at SourceForge now if you want to try it.

Thanks Jules,

I tried it and it works. There is one problem however, in the AudioUnitWrapper you have this:

void deleteUI()
    // there's some kind of component currently modal, but the host
    // is trying to delete our plugin..
    jassert (Component::getCurrentlyModalComponent() == 0);

I call the PopupMenu::dismissAllActiveMenus() in my UI class destructor, but this assert will fail since the menu is still modal.


Ok, looks to me like the deletUI method is actually the place that dismissAllActiveMenus() should get called, just before the assertion. I’ve made that change now, and also done it in the vst and rtas wrappers.

Yeah I just did that as well…

Thanks for rapid response!