I’m finding it hard to manage the lifetime of the FileChooser with the launchAsync command. My current setup works like this, and it works on macOS, but on Windows my app hangs when ‘cancel’ is clicked. It works fine when a file is chosen, though.
auto fc = std::make_shared<juce::FileChooser> ("Choose", "C:", "*", true);
int flags = juce::FileBrowserComponent::canSelectFiles |= juce::FileBrowserComponent::openMode;
fc->launchAsync (flags, [fc] (juce::FileChooser& fc) {
if (auto f = fc->getResult(); f.exists())
doSomething (f);
});
If I don’t capture the shared_ptr into the callback, the dialog never appears (or is immediately cancelled).
edit: Ah, the commit mentioned at the end of this thread fixes the problem.
