CallOutBox & lnf crash


Why the hell does this crash? Am I doing a silly mistake?
Can't I safely assume the calloutbox and its child components will be destroyed before the lnf?
 

to reproduce:
- build the audiounit and run
- click the button to open the callout
- close the GUI
 


class JuceDemoPluginAudioProcessorEditor  : public AudioProcessorEditor,
                                                                         public Button::Listener
{
public:
    JuceDemoPluginAudioProcessorEditor (JuceDemoPluginAudioProcessor& p)
    : AudioProcessorEditor (p)
    {
        addAndMakeVisible (button);
        button.addListener (this);
        setSize (400, 400);
    }
    ~JuceDemoPluginAudioProcessorEditor() {}
    //==============================================================================
    void buttonClicked (Button*) override
    {
        ListBox* testsListBox = new ListBox();
        testsListBox->setModel (&listModel);
        testsListBox->setSize (300, 100);
        CallOutBox& cob = CallOutBox::launchAsynchronously (testsListBox, button.getScreenBounds(), this);
        cob.setLookAndFeel (&lnfV2);
    }


    class TestListModel : public ListBoxModel
    {
        public:
            TestListModel() {}
            int getNumRows() override { return 100; }
            void paintListBoxItem (int row, Graphics& g, int w, int h, bool rowIsSelected) override {}
    };

    //==============================================================================
    void paint (Graphics& g) override {   g.fillAll (Colours::darkblue);        }
    void resized() override           {   button.setBounds (50, 50, 100, 100);  }

private:
    //==============================================================================
    LookAndFeel_V2 lnfV2;
    TestListModel listModel;
    TextButton button;


    JuceDemoPluginAudioProcessor& getProcessor() const
    {
        return static_cast<JuceDemoPluginAudioProcessor&> (processor);
    }
};
 

If you close the window then your calloutbox will still be running, but you'll be deleting its look+feel, so yes, it could easily crash.

I thought the call out box would be destroyed when its parent is destroyed. There's no such mechanism?

No, components don't delete their children unless you tell them to.

ah yes! not sure why I was expecting that here.. Anyway, silly mistake it was then :)
thanks Jules!