How to solve the leak with DialogWindow::showModalDialog()?


#1

Hi there,

I’ve got memory leak message when my application quits after showing/closing the dialog window which is shown by DialogWindow::showModalDialog(). (Using JUCE v1.36.)

The content component is purely created by the latest Jucer with no specific methods/members are added.

Although I set a breakpoint at the destructor of the dialog, it’s never been stopped when the dialog is closed by clicking the close button and the dialog is closed. So the destructor is not called and all of the components in the dialog are never been freed.

The code displaying the dialog is simply

DialogWindow::showModalDialog(T("Preferences"), new CPreferencesPane, this, Colours::lightgray, true);
and it’s is called when the text button on another component is clicked. (this points that component, CPreferencesPane is exported by Jucer)

How should I free that dialog?

Best regards,
Masanao Hayashi


#2

If you read the help for showModalDialog(), you’ll see that it doesn’t delete the component you pass in (because you may want to use it again, or check its state after it’s been used). So just delete it when you’re done.

I usually do it as a stack object, which is neater - have a look in AudioDemo.cpp


#3

Ah…! (I’ve just seen the AudioDemo.cpp)
I was sorry for the stupid question… That’s my shame. :oops:

Masa


#4