1
0
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:
Paul Licameli
2016-03-31 09:42:16 -04:00
parent 3481e678ea
commit a9afad17ca
9 changed files with 60 additions and 46 deletions

View File

@@ -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;