i use Juce 6.1.4 on Mac M1 ARM Mac OS 12.0.1, XCode 13.1.
I program a simple GUI with a button to choose a directory. The GUI always crashs directly when clicking the button. I don’t know why. Code see below. Thank you for help.
void MainComponent::buttonClicked(juce::Button* button)
if (button == &myButton)
juce::FileChooser fc (“title”,juce::File(),"*",false);
int flags = juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectDirectories;
auto callback = (const juce::FileChooser& fileChooser)
auto files = fileChooser.getResults();
fc.launchAsync (flags, callback);
Your FileChooser is on the stack, whereas it should be cached somewhere.
It is destroyed right now at the end of the buttonClicked call.
There’s a simple example into the documentation with a global variable.
Thanks for reporting this issue. Although the code you posted won’t work as you expect (as @nicolasdanet pointed out, the FileChooser will go out of scope immediately, closing the dialog), the program shouldn’t crash. The crash is due to a bug in JUCE, and I’ll fix this behaviour shortly.