Memory leak: ComboBox in a CallOutBox

Hi Jules,

My code leaks a TypefaceCache when:

  1. I have a ComboBox embedded in an asynchronous CallOutBox
  2. The application exits before the CallOutBox has been dismissed

CallOutBox::launchAsynchronously(new ComboBox, getScreenBounds(), nullptr);

I am on OS X 10.10.

Well, if you don’t delete the CallOutBox and leave it running during shutdown, then it could leak all kinds of things.

If you’re firing off callout boxes like this then you probably want to do something like the Projucer does in its shutdown code, where it makes sure that any active modal windows have been closed before quitting.

Thanks for pointing me to the shutdown code in the Projucer. That worked. Thanks Jules!

Is there any way to do this in a plugin? I’m following the docs on the CallOutBox page creating with a unique_ptr, but as it’s not an application I can’t do the trick in ProJucer as it uses a wait.

I’m loading a custom component into the CallOutBox. If the component has a slider in there’s no leak, only a combobox.

You may provide a parent component to the CallOutBox. After that, the CallOutBox will be deleted during the destruction of the parent component.

auto &box = juce::CallOutBox::launchAsynchronously(std::move(colourSelector),
                                                   parentC.getLocalArea(this, getLocalBounds()),
                                                   &parentC);