PluginDirectoryScanner has a feature which can easily cause problems:
PluginDirectoryScanner constructor automatically does a recursive file search through all the given plugin folders, before letting the application do anything else.
This would be fine if only the default plugin folders were used. But if the end user is allowed to add their own custom plugin folders, and he accidentally adds the root folder (or anything close to it) as a custom plugin folder, the PluginDirectoryScanner constructor ends up spending immense amount of time going through the hole harddisk.
Currently there doesn’t seem to be any way to stop this initial scan, if such an accident happens by the end user.
How to overcome this issue? As it all happens inside the PluginDirectoryScanner’s constructor, there doesn’t seem to be a nice way to stop it mid process.
The PluginListComponent uses PluginDirectoryScanner internally. To avoid this issue, the PluginListComponent checks the scan paths before creating an instance of the PluginDirectoryScanner, and allows the user to cancel the scan if any of the scan paths are suspect.
Another option might be to pass an empty FileSearchPath to the PluginDirectoryScanner, and to instead call
setFilesOrIdentifiersToScan after construction. However, I think at some point you’ll need to call
format.searchPathsForPlugins, which might take a while for a recursive search.
If you really need to be able to cancel during the search for potential plugin files, you may need to write such a function yourself (e.g. call
recursive: false, then handle the recursion yourself, but check to see whether the scan was cancelled before recursing).
OK, found the solution from PluginListComponent. It has the following method:
static bool isStupidPath (const File& f)
Pretty self descriptive I’ll use that and see what happens.
Works fine now with minimal changes.