mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added options to PluginListComponent and PluginDirectoryScanner to allow scanning of a specific set of files
This commit is contained in:
parent
f71df8704a
commit
bb5bbf32a9
4 changed files with 45 additions and 18 deletions
|
|
@ -47,18 +47,7 @@ PluginDirectoryScanner::PluginDirectoryScanner (KnownPluginList& listToAddTo,
|
|||
allowAsync (allowPluginsWhichRequireAsynchronousInstantiation)
|
||||
{
|
||||
directoriesToSearch.removeRedundantPaths();
|
||||
|
||||
filesOrIdentifiersToScan = format.searchPathsForPlugins (directoriesToSearch, recursive, allowAsync);
|
||||
|
||||
// If any plugins have crashed recently when being loaded, move them to the
|
||||
// end of the list to give the others a chance to load correctly..
|
||||
for (auto& crashed : readDeadMansPedalFile (deadMansPedalFile))
|
||||
for (int j = filesOrIdentifiersToScan.size(); --j >= 0;)
|
||||
if (crashed == filesOrIdentifiersToScan[j])
|
||||
filesOrIdentifiersToScan.move (j, -1);
|
||||
|
||||
applyBlacklistingsFromDeadMansPedal (listToAddTo, deadMansPedalFile);
|
||||
nextIndex.set (filesOrIdentifiersToScan.size());
|
||||
setFilesOrIdentifiersToScan (format.searchPathsForPlugins (directoriesToSearch, recursive, allowAsync));
|
||||
}
|
||||
|
||||
PluginDirectoryScanner::~PluginDirectoryScanner()
|
||||
|
|
@ -67,6 +56,21 @@ PluginDirectoryScanner::~PluginDirectoryScanner()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void PluginDirectoryScanner::setFilesOrIdentifiersToScan (const StringArray& filesOrIdentifiers)
|
||||
{
|
||||
filesOrIdentifiersToScan = filesOrIdentifiers;
|
||||
|
||||
// If any plugins have crashed recently when being loaded, move them to the
|
||||
// end of the list to give the others a chance to load correctly..
|
||||
for (auto& crashed : readDeadMansPedalFile (deadMansPedalFile))
|
||||
for (int j = filesOrIdentifiersToScan.size(); --j >= 0;)
|
||||
if (crashed == filesOrIdentifiersToScan[j])
|
||||
filesOrIdentifiersToScan.move (j, -1);
|
||||
|
||||
applyBlacklistingsFromDeadMansPedal (list, deadMansPedalFile);
|
||||
nextIndex.set (filesOrIdentifiersToScan.size());
|
||||
}
|
||||
|
||||
String PluginDirectoryScanner::getNextPluginFileThatWillBeScanned() const
|
||||
{
|
||||
return format.getNameOfPluginFromIdentifier (filesOrIdentifiersToScan [nextIndex.get() - 1]);
|
||||
|
|
|
|||
|
|
@ -72,6 +72,12 @@ public:
|
|||
~PluginDirectoryScanner();
|
||||
|
||||
//==============================================================================
|
||||
/** Sets a specific list of filesOrIdentifiersToScan to scan.
|
||||
N.B. This list must match the format passed to the constructor.
|
||||
@see AudioPluginFormat::searchPathsForPlugins
|
||||
*/
|
||||
void setFilesOrIdentifiersToScan (const StringArray& filesOrIdentifiersToScan);
|
||||
|
||||
/** Tries the next likely-looking file.
|
||||
|
||||
If dontRescanIfAlreadyInList is true, then the file will only be loaded and
|
||||
|
|
|
|||
|
|
@ -338,10 +338,10 @@ void PluginListComponent::setLastSearchPath (PropertiesFile& properties, AudioPl
|
|||
class PluginListComponent::Scanner : private Timer
|
||||
{
|
||||
public:
|
||||
Scanner (PluginListComponent& plc, AudioPluginFormat& format, PropertiesFile* properties,
|
||||
bool allowPluginsWhichRequireAsynchronousInstantiation, int threads,
|
||||
Scanner (PluginListComponent& plc, AudioPluginFormat& format, const StringArray& filesOrIdentifiers,
|
||||
PropertiesFile* properties, bool allowPluginsWhichRequireAsynchronousInstantiation, int threads,
|
||||
const String& title, const String& text)
|
||||
: owner (plc), formatToScan (format), propertiesToUse (properties),
|
||||
: owner (plc), formatToScan (format), filesOrIdentifiersToScan (filesOrIdentifiers), propertiesToUse (properties),
|
||||
pathChooserWindow (TRANS("Select folders to scan..."), String(), AlertWindow::NoIcon),
|
||||
progressWindow (title, text, AlertWindow::NoIcon),
|
||||
progress (0.0), numThreads (threads), allowAsync (allowPluginsWhichRequireAsynchronousInstantiation),
|
||||
|
|
@ -352,7 +352,9 @@ public:
|
|||
// You need to use at least one thread when scanning plug-ins asynchronously
|
||||
jassert (! allowAsync || (numThreads > 0));
|
||||
|
||||
if (path.getNumPaths() > 0) // if the path is empty, then paths aren't used for this format.
|
||||
// If the filesOrIdentifiersToScan argumnent isn't empty, we should only scan these
|
||||
// If the path is empty, then paths aren't used for this format.
|
||||
if (filesOrIdentifiersToScan.isEmpty() && path.getNumPaths() > 0)
|
||||
{
|
||||
#if ! JUCE_IOS
|
||||
if (propertiesToUse != nullptr)
|
||||
|
|
@ -389,6 +391,7 @@ public:
|
|||
private:
|
||||
PluginListComponent& owner;
|
||||
AudioPluginFormat& formatToScan;
|
||||
StringArray filesOrIdentifiersToScan;
|
||||
PropertiesFile* propertiesToUse;
|
||||
ScopedPointer<PluginDirectoryScanner> scanner;
|
||||
AlertWindow pathChooserWindow, progressWindow;
|
||||
|
|
@ -482,7 +485,11 @@ private:
|
|||
scanner.reset (new PluginDirectoryScanner (owner.list, formatToScan, pathList.getPath(),
|
||||
true, owner.deadMansPedalFile, allowAsync));
|
||||
|
||||
if (propertiesToUse != nullptr)
|
||||
if (! filesOrIdentifiersToScan.isEmpty())
|
||||
{
|
||||
scanner->setFilesOrIdentifiersToScan (filesOrIdentifiersToScan);
|
||||
}
|
||||
else if (propertiesToUse != nullptr)
|
||||
{
|
||||
setLastSearchPath (*propertiesToUse, formatToScan, pathList.getPath());
|
||||
propertiesToUse->saveIfNeeded();
|
||||
|
|
@ -560,7 +567,12 @@ private:
|
|||
|
||||
void PluginListComponent::scanFor (AudioPluginFormat& format)
|
||||
{
|
||||
currentScanner.reset (new Scanner (*this, format, propertiesToUse, allowAsync, numThreads,
|
||||
scanFor (format, StringArray());
|
||||
}
|
||||
|
||||
void PluginListComponent::scanFor (AudioPluginFormat& format, const StringArray& filesOrIdentifiersToScan)
|
||||
{
|
||||
currentScanner.reset (new Scanner (*this, format, filesOrIdentifiersToScan, propertiesToUse, allowAsync, numThreads,
|
||||
dialogTitle.isNotEmpty() ? dialogTitle : TRANS("Scanning for plug-ins..."),
|
||||
dialogText.isNotEmpty() ? dialogText : TRANS("Searching for all possible plug-in files...")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ public:
|
|||
/** Triggers an asynchronous scan for the given format. */
|
||||
void scanFor (AudioPluginFormat&);
|
||||
|
||||
/** Triggers an asynchronous scan for the given format and scans only the given files or identifiers.
|
||||
@see AudioPluginFormat::searchPathsForPlugins
|
||||
*/
|
||||
void scanFor (AudioPluginFormat&, const StringArray& filesOrIdentifiersToScan);
|
||||
|
||||
/** Returns true if there's currently a scan in progress. */
|
||||
bool isScanning() const noexcept;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue