MCPcopy Create free account
hub / github.com/audacity/audacity / Discover

Function Discover

libraries/lib-module-manager/PluginHost.cpp:31–74  ·  view source on GitHub ↗

Attempts to instantiate plugin module and put plugin descriptors into result

Source from the content-addressed store, hash-verified

29{
30 //Attempts to instantiate plugin module and put plugin descriptors into result
31 void Discover(detail::PluginValidationResult& result, const wxString& providerId, const wxString& pluginPath)
32 {
33 try
34 {
35 if(auto provider = ModuleManager::Get().CreateProviderInstance(providerId, wxEmptyString))
36 {
37 TranslatableString errorMessage{};
38 auto validator = provider->MakeValidator();
39 auto numPlugins = provider->DiscoverPluginsAtPath(
40 pluginPath, errorMessage, [&](PluginProvider *provider, ComponentInterface *ident) -> const PluginID&
41 {
42 //Workaround: use DefaultRegistrationCallback to create all descriptors for us
43 //and then put a copy into result
44 auto& id = PluginManager::DefaultRegistrationCallback(provider, ident);
45 if(const auto ptr = PluginManager::Get().GetPlugin(id))
46 {
47 auto desc = *ptr;
48 try
49 {
50 if(validator)
51 validator->Validate(*ident);
52 }
53 catch(...)
54 {
55 desc.SetEnabled(false);
56 desc.SetValid(false);
57 }
58 result.Add(std::move(desc));
59 }
60 return id;
61 });
62 if(!errorMessage.empty())
63 result.SetError(errorMessage.Debug());
64 else if(numPlugins == 0)
65 result.SetError("no plugins found");
66 }
67 else
68 result.SetError("provider not found");
69 }
70 catch(...)
71 {
72 result.SetError("unknown error");
73 }
74 }
75}
76
77PluginHost::PluginHost(int connectPort)

Callers 1

ServeMethod · 0.85

Calls 12

GetFunction · 0.85
moveFunction · 0.85
SetValidMethod · 0.80
MakeValidatorMethod · 0.45
DiscoverPluginsAtPathMethod · 0.45
GetPluginMethod · 0.45
ValidateMethod · 0.45
SetEnabledMethod · 0.45
AddMethod · 0.45
emptyMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected