c++audioexc-bad-accessjuce

Why is this code resulting in bad access?


WildcardFileFilter wavFiles = WildcardFileFilter("*.wav", "", "wavFiles");

fileChooser = new FileBrowserComponent(
                   FileBrowserComponent::FileChooserFlags::openMode
                   | FileBrowserComponent::FileChooserFlags::canSelectFiles
                   | FileBrowserComponent::FileChooserFlags::canSelectDirectories,
                   File("/Users/harrygardiner/Desktop"), &wavFiles, nullptr);

I'm trying to isolate .wav files in my audio application but it keeps telling me I have bad access problems, why is this?


Solution

  • Your wavFiles lives on the Stack. fileChooser is probably outliving wavFiles and then tries to access it resulting in undefined behaviour.