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);
}
};