1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-19 09:01:15 +02:00

Simplify memory management in PluginManager

This commit is contained in:
Paul Licameli
2021-06-18 13:08:36 -04:00
parent 4770b1f0a4
commit 8fda526577
24 changed files with 96 additions and 192 deletions

View File

@@ -236,27 +236,16 @@ bool VampEffectsModule::IsPluginValid(const PluginPath & path, bool bFast)
return bool(vp);
}
ComponentInterface *VampEffectsModule::CreateInstance(const PluginPath & path)
std::unique_ptr<ComponentInterface>
VampEffectsModule::CreateInstance(const PluginPath & path)
{
// Acquires a resource for the application.
int output;
bool hasParameters;
auto vp = FindPlugin(path, output, hasParameters);
if (vp)
{
// Safety of this depends on complementary calls to DeleteInstance on the module manager side.
return safenew VampEffect(std::move(vp), path, output, hasParameters);
}
return NULL;
}
void VampEffectsModule::DeleteInstance(ComponentInterface *instance)
{
std::unique_ptr < VampEffect > {
dynamic_cast<VampEffect *>(instance)
};
if (auto vp = FindPlugin(path, output, hasParameters))
return std::make_unique<VampEffect>(std::move(vp), path, output, hasParameters);
return nullptr;
}
// VampEffectsModule implementation

View File

@@ -58,8 +58,8 @@ public:
bool IsPluginValid(const PluginPath & path, bool bFast) override;
ComponentInterface *CreateInstance(const PluginPath & path) override;
void DeleteInstance(ComponentInterface *instance) override;
std::unique_ptr<ComponentInterface>
CreateInstance(const PluginPath & path) override;
private:
// VampEffectModule implementation