I’m not sure if this is expected behavior, but I don’t see how it can be.
If you launch an AlertWindow in your plugin (async with autoDelete), then delete the plugin (right-click) with the Alert open, you hit an assert. If you then close the AudioPluginHost, you get memory leaks.
I am calling juce::ModalComponentManager::getInstance()->cancelAllModalComponents();
in the AudioProcessorEditor destructor.
I’m testing this in AudioPluginHost, Juce 6.1.6. MacOS Mojave.
A demo project is attached:
AlertTest.zip (26.7 KB)
Steps to reproduce:
- debug the TestAlert project into AudioPluginHost.
- after APH is launched, add a instance of your company > TestAlert VST3. Open the editor.
- click the Alert button - alert pops up.
- right click on TestAlert plugin and “delete filter”.
- Assert hits :
JUCE v6.1.6
JUCE Assertion failure in juce_DeletedAtShutdown.cpp:82
- Continue in the debugger.
- Quit AudioPluginHost, answer “Discard” to changes.
Memory leaks:
*** Leaked objects detected: 1 instance(s) of class TimerThread
JUCE Assertion failure in juce_LeakedObjectDetector.h:92
*** Leaked objects detected: 1 instance(s) of class Thread
JUCE Assertion failure in juce_LeakedObjectDetector.h:92
*** Leaked objects detected: 3 instance(s) of class WaitableEvent
JUCE Assertion failure in juce_LeakedObjectDetector.h:92
… etc
Thought this might be related, but it doesn’t seem to apply:
Here’s the relevant source:
//==============================================================================
AlertTestAudioProcessorEditor::AlertTestAudioProcessorEditor (AlertTestAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (800, 500);
addAndMakeVisible(alertButton);
alertButton.onClick = [this] {
auto* aw = new juce::AlertWindow("This is a test...", {}, juce::AlertWindow::InfoIcon, this);
aw->addButton ("OK", 0, juce::KeyPress (juce::KeyPress::returnKey));
aw->enterModalState (true,
juce::ModalCallbackFunction::create
([this] (int result)
{
if (result == 1) // OK
DBG ("result = 1");
}), true);
};
}
AlertTestAudioProcessorEditor::~AlertTestAudioProcessorEditor()
{
juce::ModalComponentManager::getInstance()->cancelAllModalComponents();
}
//==============================================================================
void AlertTestAudioProcessorEditor::paint (juce::Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
g.setColour (juce::Colours::white);
g.setFont (15.0f);
g.drawFittedText ("Hello World!", getLocalBounds(), juce::Justification::centred, 1);
}
void AlertTestAudioProcessorEditor::resized()
{
// This is generally where you'll want to lay out the positions of any
// subcomponents in your editor..
alertButton.setBounds(20, 20, 100, 30);
}