Recommended way to browse for files in plugins?


It looks like that at least in Windows, the JUCE FileChooser::browseForFileToOpen does not work truly modally for (VST2) plugins. It is possible for the user to close the plugin window while the file dialog is still open. This obviously leads to a disaster. (I suspect this happens on macOs too since a Logic user prompted me to start testing this but I didn’t yet test on macOs.)

Is there some solution for this while still using FileChooser, or is it really necessary to do some kind of a non-modal custom file selection Component embedded in the plugin’s GUI?

edit : OK, looks like FileChooser::launchAsync kind of fixes the original problem but brings in new ones : the opened (native) file dialog on Windows has the 1990’s look and feel and on quitting the host I get a JUCE detected memory leak for StringArray that I have no idea where it is coming from.

edit2 : Actually launchAsync doesn’t help. Because the opened dialog is still non-modal, it’s possible to delete the whole plugin instance while the file dialog is open. Which leads to an instant crash.

edit3 : Nevermind. I just went with the FileBrowserComponent overlaid on the plugin GUI. Actually works nicer than the file dialog… :slight_smile: