In JUCE 1.23, this worked beautifully:[code]#include <juce.h>
class AudioSettingsDialog : public DialogWindow
{
public:
AudioSettingsDialog (AudioDeviceManager& audioDeviceManager) : DialogWindow (T(“Audio Settings”), Colours::lightgrey, true)
{
centreWithSize (500, 300);
AudioDeviceSelectorComponent* audioControlComp = new AudioDeviceSelectorComponent (audioDeviceManager, 0, 0, 0, 2, false);
audioControlComp->setBounds(0, DEFAULTTITLEBARHEIGHT, getWidth(), getHeight()-100);
addAndMakeVisible (audioControlComp);
TextButton* m_okay = new TextButton(T("Okay"));
m_okay->setBounds(getWidth()-180, getHeight()-60, 60, 25);
m_okay->addButtonListener(this);
addAndMakeVisible(m_okay);
TextButton* m_cancel = new TextButton(T("Cancel"));
m_cancel->setBounds(getWidth()-100, getHeight()-60, 60, 25);
m_cancel->addButtonListener(this);
addAndMakeVisible(m_cancel);
setVisible (true);
toFront(true);
}
~AudioSettingsDialog()
{
}
void closeButtonPressed()
{
exitModalState(0);
}
void buttonClicked (Button* button)
{
exitModalState (button->getButtonText() == T("Okay"));
}
};
class MyApp : public JUCEApplication
{
AudioDeviceManager* dm;
public:
MyApp()
{
}
~MyApp()
{
}
void initialise (const String& commandLine)
{
dm = new AudioDeviceManager;
dm->initialise(0,2,0);
AudioSettingsDialog d(*dm);
if(d.runModalLoop ())
{
// Do something
AlertWindow::showMessageBox(AlertWindow::InfoIcon, T(“Success”), T(“Audio settings successfuly changed.”));
JUCEApplication::quit();
}
else
{
JUCEApplication::quit();
}
}
void shutdown()
{
delete dm;
}
const String getApplicationName()
{
return T("MyApp");
}
const String getApplicationVersion()
{
return T("1.0");
}
};
START_JUCE_APPLICATION(MyApp)[/code]In JUCE 1.24, I get a ton of memory leaks. If delete the components in the dialog manually, then all is well. Of course, if I put in deleteAllChildren() in the destructor it throws an exception, so I can’t do that. Am I doing something naughty?
- kbj