Juce Demo Synth - BAD ACCESS


#1

Hi everyone. I’m starting to build a standalone synth. I’ve used Jucer to create the basic interface. Then generated a main file for XCode using IntroJucer. Then added the .cpp and .h files generated by the Jucer to the XCode project. I added the necessary code so that the program launches correctly. Now I’m adding code from the Juce Demo synth to mine and all is going pretty well except for one weird error:

When I add this line of code from the Juce Demo synth into my main component destructor:

my program still launches correctly but, when I try to quit the program it freezes and I get the following error in XCode:

I ran the Juce Demo from within XCode and quit it without a problem. Any ideas why this is happening?

Thanks in advance.


#2

I assume synthAudioSource is deleted before deviceManager.removeMidiInputCallback() is called.

Chris


#3

Possibly. The code in my main component’s destructor is:

deviceManager.removeAudioCallback(&audioSourcePlayer); deviceManager.removeMidiInputCallback(String::empty, &(synthAudioSource->midiCollector)); audioSourcePlayer.setSource (0);

The synthAudioSource was created as a ScopedPointer, which I’m assuming that means it’s automatically deleted when the main component is deleted, which is why there’s no mention of it in the Destructor? And if that’s true, since midiCollector is a member of synthAudioSource, does that mean it also is deleted autmoatically, and therefore there’s no need for me to do it?