Skip to content

Commit

Permalink
ModuleManager doesn't use PluginManager to initialize providers
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Licameli committed Jul 1, 2021
1 parent 2e7f711 commit 02b6153
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
23 changes: 3 additions & 20 deletions src/ModuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,29 +448,15 @@ 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;
}

void ModuleManager::InitializeBuiltins()
{
PluginManager & pm = PluginManager::Get();

for (auto moduleMain : builtinModuleList())
{
ModuleInterfaceHandle module {
Expand All @@ -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
{
Expand Down
7 changes: 6 additions & 1 deletion src/ModuleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#ifndef __AUDACITY_MODULEMANAGER_H__
#define __AUDACITY_MODULEMANAGER_H__

#include <memory>
#include "MemoryX.h"
#include <functional>
#include <map>
#include <vector>

Expand Down Expand Up @@ -98,6 +99,10 @@ class AUDACITY_DLL_API ModuleManager final
// 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);
Expand Down
9 changes: 7 additions & 2 deletions src/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 02b6153

Please sign in to comment.