mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-08 06:03:49 +01:00
Remove some naked new amd delete in: various
This commit is contained in:
committed by
Paul Licameli
parent
186679b3a6
commit
942c62b6f6
@@ -55,13 +55,6 @@ EffectManager::~EffectManager()
|
||||
// wxWidgets has already destroyed the rack since it was derived from wxFrame. So
|
||||
// no need to DELETE it here.
|
||||
#endif
|
||||
|
||||
EffectMap::iterator iter = mHostEffects.begin();
|
||||
while (iter != mHostEffects.end())
|
||||
{
|
||||
delete iter->second;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
// Here solely for the purpose of Nyquist Workbench until
|
||||
@@ -706,13 +699,11 @@ Effect *EffectManager::GetEffect(const PluginID & ID)
|
||||
// TODO: This is temporary and should be redone when all effects are converted
|
||||
if (mEffects.find(ID) == mEffects.end())
|
||||
{
|
||||
Effect *effect;
|
||||
|
||||
// This will instantiate the effect client if it hasn't already been done
|
||||
EffectIdentInterface *ident = dynamic_cast<EffectIdentInterface *>(PluginManager::Get().GetInstance(ID));
|
||||
if (ident && ident->IsLegacy())
|
||||
{
|
||||
effect = dynamic_cast<Effect *>(ident);
|
||||
auto effect = dynamic_cast<Effect *>(ident);
|
||||
if (effect && effect->Startup(NULL))
|
||||
{
|
||||
mEffects[ID] = effect;
|
||||
@@ -720,18 +711,17 @@ Effect *EffectManager::GetEffect(const PluginID & ID)
|
||||
}
|
||||
}
|
||||
|
||||
effect = new Effect();
|
||||
auto effect = std::make_shared<Effect>(); // TODO: use make_unique and store in std::unordered_map
|
||||
if (effect)
|
||||
{
|
||||
EffectClientInterface *client = dynamic_cast<EffectClientInterface *>(ident);
|
||||
if (client && effect->Startup(client))
|
||||
{
|
||||
mEffects[ID] = effect;
|
||||
mHostEffects[ID] = effect;
|
||||
return effect;
|
||||
auto pEffect = effect.get();
|
||||
mEffects[ID] = pEffect;
|
||||
mHostEffects[ID] = std::move(effect);
|
||||
return pEffect;
|
||||
}
|
||||
|
||||
delete effect;
|
||||
}
|
||||
|
||||
wxMessageBox(wxString::Format(_("Attempting to initialize the following effect failed:\n\n%s\n\nMore information may be available in Help->Show Log"),
|
||||
|
||||
@@ -35,6 +35,7 @@ effects.
|
||||
|
||||
WX_DEFINE_USER_EXPORTED_ARRAY(Effect *, EffectArray, class AUDACITY_DLL_API);
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(Effect *, EffectMap, class AUDACITY_DLL_API);
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(std::shared_ptr<Effect>, EffectOwnerMap, class AUDACITY_DLL_API);
|
||||
|
||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||
class EffectRack;
|
||||
@@ -127,7 +128,7 @@ private:
|
||||
|
||||
private:
|
||||
EffectMap mEffects;
|
||||
EffectMap mHostEffects;
|
||||
EffectOwnerMap mHostEffects;
|
||||
|
||||
int mNumEffects;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user