1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 08:29:27 +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);
#endif
PluginManager & pm = PluginManager::Get();
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);
}
}
for ( const auto &path : provList )
LoadModule(path);
#endif
return true;
@ -469,8 +457,6 @@ bool ModuleManager::DiscoverProviders()
void ModuleManager::InitializeBuiltins()
{
PluginManager & pm = PluginManager::Get();
for (auto moduleMain : builtinModuleList())
{
ModuleInterfaceHandle module {
@ -481,13 +467,10 @@ void ModuleManager::InitializeBuiltins()
{
// Register the provider
ModuleInterface *pInterface = module.get();
const PluginID & id = pm.RegisterPlugin(pInterface);
auto id = GetID(pInterface);
// Need to remember it
mDynModules[id] = std::move(module);
// Allow the module to auto-register children
pInterface->AutoRegisterPlugins(pm);
}
else
{

View File

@ -12,7 +12,8 @@
#ifndef __AUDACITY_MODULEMANAGER_H__
#define __AUDACITY_MODULEMANAGER_H__
#include <memory>
#include "MemoryX.h"
#include <functional>
#include <map>
#include <vector>
@ -98,6 +99,10 @@ public:
// Can be called before Initialize()
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);
bool RegisterEffectPlugin(const PluginID & provider, const PluginPath & path,
TranslatableString &errMsg);

View File

@ -722,8 +722,13 @@ void PluginManager::Initialize()
// And force load of setting to verify it's accessible
GetSettings();
// Then look for providers (they may autoregister plugins)
ModuleManager::Get().DiscoverProviders();
auto &mm = ModuleManager::Get();
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
#ifndef EXPERIMENTAL_EFFECT_MANAGEMENT