diff --git a/include/audacity/ModuleInterface.h b/include/audacity/ModuleInterface.h index 68f624f59..b1ec9d11e 100644 --- a/include/audacity/ModuleInterface.h +++ b/include/audacity/ModuleInterface.h @@ -116,7 +116,8 @@ public: // even if some plugins are also discovered successfully. // Return value is the number of plugins found. using RegistrationCallback = - std::function< void(ModuleInterface *, EffectIdentInterface *) >; + std::function< + const PluginID &(ModuleInterface *, EffectIdentInterface *) >; virtual unsigned DiscoverPluginsAtPath( const wxString & path, wxString &errMsg, const RegistrationCallback &callback = diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index d92c20c91..8e8239cba 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1761,8 +1761,8 @@ bool PluginManager::DropFile(const wxString &fileName) if (!ff.empty() && module->PathsAreFiles()) { wxString errMsg; // Do dry-run test of the file format - unsigned nPlugIns = module->DiscoverPluginsAtPath(fileName, errMsg, - [](ModuleInterface *, EffectIdentInterface *){}); + unsigned nPlugIns = + module->DiscoverPluginsAtPath(fileName, errMsg, {}); if (nPlugIns) { // File contents are good for this module, so check no others. // All branches of this block return true, even in case of @@ -1813,10 +1813,12 @@ bool PluginManager::DropFile(const wxString &fileName) [&](ModuleInterface *provider, EffectIdentInterface *ident){ // Register as by default, but also collecting the PluginIDs // and names - ids.push_back( + const auto &id = PluginManagerInterface::DefaultRegistrationCallback( - provider, ident) ); + provider, ident); + ids.push_back(id); names.push_back( wxGetTranslation( ident->GetName() ) ); + return id; }); if ( ! nPlugIns ) { // Unlikely after the dry run succeeded diff --git a/src/effects/LoadEffects.cpp b/src/effects/LoadEffects.cpp index 3eae7039e..298c9c3f8 100644 --- a/src/effects/LoadEffects.cpp +++ b/src/effects/LoadEffects.cpp @@ -319,7 +319,8 @@ unsigned BuiltinEffectsModule::DiscoverPluginsAtPath( auto effect = Instantiate(path); if (effect) { - callback(this, effect.get()); + if (callback) + callback(this, effect.get()); return 1; } diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 21b8c44ca..fd9405a4a 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -630,7 +630,8 @@ unsigned VSTEffectsModule::DiscoverPluginsAtPath( if (!skip && cont) { valid = true; - callback( this, &proc ); + if (callback) + callback( this, &proc ); ++nFound; } } diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 00c499067..5009093e4 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -193,7 +193,9 @@ unsigned AudioUnitEffectsModule::DiscoverPluginsAtPath( return 0; } - callback(this, &effect); + if(callback) + callback(this, &effect); + return 1; } diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 5aed54616..cc5167983 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -250,7 +250,8 @@ unsigned LadspaEffectsModule::DiscoverPluginsAtPath( LadspaEffect effect(path, index); if (effect.SetHost(NULL)) { ++nLoaded; - callback( this, &effect ); + if (callback) + callback( this, &effect ); } else errMsg = _("Could not load the library"); diff --git a/src/effects/lv2/LoadLV2.cpp b/src/effects/lv2/LoadLV2.cpp index 8f12a3cea..3f13ee9b5 100644 --- a/src/effects/lv2/LoadLV2.cpp +++ b/src/effects/lv2/LoadLV2.cpp @@ -253,7 +253,8 @@ unsigned LV2EffectsModule::DiscoverPluginsAtPath( LV2Effect effect(plug); if (effect.SetHost(NULL)) { - callback( this, &effect ); + if (callback) + callback( this, &effect ); return 1; } } diff --git a/src/effects/nyquist/LoadNyquist.cpp b/src/effects/nyquist/LoadNyquist.cpp index c60226f18..b65f4b68f 100644 --- a/src/effects/nyquist/LoadNyquist.cpp +++ b/src/effects/nyquist/LoadNyquist.cpp @@ -223,7 +223,8 @@ unsigned NyquistEffectsModule::DiscoverPluginsAtPath( NyquistEffect effect(path); if (effect.IsOk()) { - callback(this, &effect); + if (callback) + callback(this, &effect); return 1; } diff --git a/src/effects/vamp/LoadVamp.cpp b/src/effects/vamp/LoadVamp.cpp index 6e2ed2058..1918f4361 100644 --- a/src/effects/vamp/LoadVamp.cpp +++ b/src/effects/vamp/LoadVamp.cpp @@ -211,7 +211,8 @@ unsigned VampEffectsModule::DiscoverPluginsAtPath( if (vp) { VampEffect effect(std::move(vp), path, output, hasParameters); - callback( this, &effect ); + if (callback) + callback( this, &effect ); return 1; }