From 575725e39d7b8749703bae5c84db4d1c23c5d7d5 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 26 Jun 2013 11:57:09 +0100 Subject: [PATCH] Fix for a subtle race condition in plugin scanning. --- .../format_types/juce_AudioUnitPluginFormat.mm | 2 -- .../scanning/juce_PluginDirectoryScanner.cpp | 7 +++++-- .../scanning/juce_PluginDirectoryScanner.h | 5 ++++- .../scanning/juce_PluginListComponent.cpp | 8 +++----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index a1daeb27b2..639131268f 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -115,8 +115,6 @@ namespace AudioUnitFormatHelpers { name = String::fromCFString (cfName); CFRelease (cfName); - - DBG ("AU name: " + name); } if (name.containsChar (':')) diff --git a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp index 3c8a54289f..24eb6d27f4 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp @@ -76,16 +76,19 @@ void PluginDirectoryScanner::updateProgress() progress = (1.0f - nextIndex.get() / (float) filesOrIdentifiersToScan.size()); } -bool PluginDirectoryScanner::scanNextFile (const bool dontRescanIfAlreadyInList) +bool PluginDirectoryScanner::scanNextFile (const bool dontRescanIfAlreadyInList, + String& nameOfPluginBeingScanned) { const int index = --nextIndex; if (index >= 0) { - String file (filesOrIdentifiersToScan [index]); + const String file (filesOrIdentifiersToScan [index]); if (file.isNotEmpty() && ! list.isListingUpToDate (file, format)) { + nameOfPluginBeingScanned = format.getNameOfPluginFromIdentifier (file); + OwnedArray typesFound; // Add this plugin to the end of the dead-man's pedal list in case it crashes... diff --git a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h index bedb9d0785..2e06cb7a22 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h +++ b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h @@ -77,10 +77,13 @@ public: re-tested if it's not already in the list, or if the file's modification time has changed since the list was created. If dontRescanIfAlreadyInList is false, the file will always be reloaded and tested. + The nameOfPluginBeingScanned will be updated to the name of the plugin being + scanned before the scan starts. Returns false when there are no more files to try. */ - bool scanNextFile (bool dontRescanIfAlreadyInList); + bool scanNextFile (bool dontRescanIfAlreadyInList, + String& nameOfPluginBeingScanned); /** Skips over the next file without scanning it. Returns false when there are no more files to try. diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index ce153b96cf..b604c969f4 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -365,14 +365,12 @@ private: if (finished) finishedScan(); else - progressWindow.setMessage (progressMessage); + progressWindow.setMessage (TRANS("Testing") + ":\n\n" + pluginBeingScanned); } bool doNextScan() { - progressMessage = TRANS("Testing") + ":\n\n" + scanner->getNextPluginFileThatWillBeScanned(); - - if (scanner->scanNextFile (true)) + if (scanner->scanNextFile (true, pluginBeingScanned)) { progress = scanner->getProgress(); return true; @@ -388,7 +386,7 @@ private: ScopedPointer scanner; AlertWindow pathChooserWindow, progressWindow; FileSearchPathListComponent pathList; - String progressMessage; + String pluginBeingScanned; double progress; int numThreads; bool finished;