mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-16 09:31:14 +01:00
Plugin instances managed without naked new and delete
This commit is contained in:
@@ -1053,13 +1053,17 @@ PluginDescriptor::PluginDescriptor()
|
||||
}
|
||||
|
||||
PluginDescriptor::~PluginDescriptor()
|
||||
{
|
||||
DeleteInstance();
|
||||
}
|
||||
|
||||
void PluginDescriptor::DeleteInstance()
|
||||
{
|
||||
if (mInstance)
|
||||
{
|
||||
ModuleManager::Get().DeleteInstance(GetProviderID(), mInstance);
|
||||
mInstance = nullptr;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool PluginDescriptor::IsInstantiated() const
|
||||
@@ -1086,6 +1090,12 @@ IdentInterface *PluginDescriptor::GetInstance()
|
||||
|
||||
void PluginDescriptor::SetInstance(IdentInterface *instance)
|
||||
{
|
||||
if (mInstance && mInstance != instance)
|
||||
{
|
||||
// Be sure not to leak resources!!
|
||||
DeleteInstance();
|
||||
}
|
||||
|
||||
mInstance = instance;
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user