1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-02 17:09:26 +02:00

ModuleManager doesn't use PluginManager to initialize providers

This commit is contained in:
Paul Licameli 2020-02-20 07:35:11 -05:00
parent 2e7f7114d2
commit 02b61532fe
3 changed files with 16 additions and 23 deletions

View File

@ -448,20 +448,8 @@ bool ModuleManager::DiscoverProviders()
FileNames::FindFilesInPathList(wxT("*.so"), pathList, provList); FileNames::FindFilesInPathList(wxT("*.so"), pathList, provList);
#endif #endif
PluginManager & pm = PluginManager::Get(); for ( const auto &path : provList )
LoadModule(path);
for (int i = 0, cnt = provList.size(); i < cnt; i++)
{
ModuleInterface *module = LoadModule(provList[i]);
if (module)
{
// Register the provider
pm.RegisterPlugin(module);
// Now, allow the module to auto-register children
module->AutoRegisterPlugins(pm);
}
}
#endif #endif
return true; return true;
@ -469,8 +457,6 @@ bool ModuleManager::DiscoverProviders()
void ModuleManager::InitializeBuiltins() void ModuleManager::InitializeBuiltins()
{ {
PluginManager & pm = PluginManager::Get();
for (auto moduleMain : builtinModuleList()) for (auto moduleMain : builtinModuleList())
{ {
ModuleInterfaceHandle module { ModuleInterfaceHandle module {
@ -481,13 +467,10 @@ void ModuleManager::InitializeBuiltins()
{ {
// Register the provider // Register the provider
ModuleInterface *pInterface = module.get(); ModuleInterface *pInterface = module.get();
const PluginID & id = pm.RegisterPlugin(pInterface); auto id = GetID(pInterface);
// Need to remember it // Need to remember it
mDynModules[id] = std::move(module); mDynModules[id] = std::move(module);
// Allow the module to auto-register children
pInterface->AutoRegisterPlugins(pm);
} }
else else
{ {

View File

@ -12,7 +12,8 @@
#ifndef __AUDACITY_MODULEMANAGER_H__ #ifndef __AUDACITY_MODULEMANAGER_H__
#define __AUDACITY_MODULEMANAGER_H__ #define __AUDACITY_MODULEMANAGER_H__
#include <memory> #include "MemoryX.h"
#include <functional>
#include <map> #include <map>
#include <vector> #include <vector>
@ -98,6 +99,10 @@ public:
// Can be called before Initialize() // Can be called before Initialize()
bool DiscoverProviders(); bool DiscoverProviders();
// Supports range-for iteration
auto Providers() const
{ return make_iterator_range(mDynModules.cbegin(), mDynModules.cend()); }
PluginPaths FindPluginsForProvider(const PluginID & provider, const PluginPath & path); PluginPaths FindPluginsForProvider(const PluginID & provider, const PluginPath & path);
bool RegisterEffectPlugin(const PluginID & provider, const PluginPath & path, bool RegisterEffectPlugin(const PluginID & provider, const PluginPath & path,
TranslatableString &errMsg); TranslatableString &errMsg);

View File

@ -722,8 +722,13 @@ void PluginManager::Initialize()
// And force load of setting to verify it's accessible // And force load of setting to verify it's accessible
GetSettings(); GetSettings();
// Then look for providers (they may autoregister plugins) auto &mm = ModuleManager::Get();
ModuleManager::Get().DiscoverProviders(); mm.DiscoverProviders();
for (const auto &[id, module] : mm.Providers()) {
RegisterPlugin(module.get());
// Allow the module to auto-register children
module->AutoRegisterPlugins(*this);
}
// And finally check for updates // And finally check for updates
#ifndef EXPERIMENTAL_EFFECT_MANAGEMENT #ifndef EXPERIMENTAL_EFFECT_MANAGEMENT