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:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user