Bug and crash in PopupMenu


I found two issues with the PopupMenu used in plugin’s GUI. The first leads to crash the host app (tested on Live8, FL8, Orion7), the second occurs only under Orion.

I’ve tested it on juce from the latest GIT with only few modifications in JuceDemoPlugin files.

Here is briefly what I’ve changed:

in JucePluginCharacteristics.h

#define JucePlugin_IsSynth                          1

in DemoEditorComponent.h

class DemoEditorComponent   : public AudioProcessorEditor,
                              public ChangeListener,
                              public SliderListener,
                              public ButtonListener
    void buttonClicked (Button* button);

    TextButton* testButton;

in DemoEditorComponent.cpp

DemoEditorComponent::DemoEditorComponent (DemoJuceFilter* const ownerFilter)
    : AudioProcessorEditor (ownerFilter)
    addAndMakeVisible (testButton = new TextButton ("Test"));
    testButton->addButtonListener (this);

void DemoEditorComponent::resized()
    testButton->setBounds (240, 0, 80, 20);

void DemoEditorComponent::buttonClicked (Button* button)
  if (button == testButton)
    PopupMenu menu;
    menu.addItem (1, "item 1");


    PopupMenu subMenu;
    subMenu.addItem (11, "sub item 1");
    subMenu.addItem (12, "sub item 2");
    menu.addSubMenu ("subMenu", subMenu);

    PopupMenu subMenu1;
    subMenu1.addItem (13, "sub item 3");
    subMenu1.addItem (14, "sub item 4");
    menu.addSubMenu ("subMenu1", subMenu1);

    menu.addItem (2, "item 2");

    menu.showAt (testButton);

So it’s just button added to the GUI and PopupMenu which shows up when this button is clicked.

BUG (Orion only)

Defining JuceDemoPlugin as synth is crucial for that bug. It doesn’t appear when synth flag is set to 0. Yes, I know that JuceDemoPlugin is supposed to be an effect and it behaves this way in other parts of code but I also have this bug in my synth plugin so this change in JuceDemoPlugin is just for showing the bug.

So we insert JuceDemoPlugin, then we click on Test button, we move down slowly through the “item 1” to “subMenu” (and wait a while to see the content of this submenu), and then we try to continue to move down to the “subMenu1”. But when the mouse starts to be over the “subMenu1” the whole popupMenu dissapers.

As I said crucial is to have plugin defined with JucePlugin_IsSynth=1 and moving through the item which has submenu.

CRASH (all hosts)

For that situation JucePlugin_IsSynth can be 0. Only the PopupMenu with the same structure is needed to crash the host app.

So we insert JuceDemoPlugin, we click on Test button, we move down slowly through the “item 1” to “subMenu” (and wait a while to see the content of this submenu), and then we move the mouse outside the GUI’s area. When we click to close the GUI or even click somewhere on Orion’s desktop it crashes. The submenu content HAS to be visible to reproduce it, it doesn’t happen when only the first depth level menu is visible.

In other hosts like Live or FL the situation is similar. When we move the focus to host by clicking on its desktop or try to close editor’s window it happens.

I have no idea how to fix it … anyone can help?

Just in the case - here’s the link to Orion demo - http://www.synapse-audio.com/demos/oriondemo.zip