PopupMenu causes crash


#1

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?

Thanks,

Martin Saleteg


#2

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…


#3

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?

/Martin


#4

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.


#5

Splendid.

I would very much appreciate that function.

/Martin


#6

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


#7

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.

/Martin


#8

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.


#9

Yeah I just did that as well…

Thanks for rapid response!

/Martin


#10