From a12818a912f88ddec24709f0d9b4e85af3eb23b9 Mon Sep 17 00:00:00 2001 From: lllucius Date: Tue, 10 Jun 2014 06:03:51 +0000 Subject: [PATCH] Fix memleak. Not observed, just saw it when browsing the code. --- src/commands/CommandManager.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index c3e4cf92e..015022748 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -1084,22 +1084,25 @@ bool CommandManager::HandleTextualCommand(wxString & Str, wxUint32 flags, wxUint // Not one of the singleton commands. // We could/should try all the list-style commands. // instead we only try the effects. - EffectArray *effects; - AudacityProject * proj; - proj = GetActiveProject(); + AudacityProject * proj = GetActiveProject(); if( !proj ) return false; + bool result = false; int effectFlags = ALL_EFFECTS | CONFIGURED_EFFECT; - effects = EffectManager::Get().GetEffects(effectFlags); - for(i=0; iGetCount(); i++) { - wxString effectName = (*effects)[i]->GetEffectName(); - if( Str.IsSameAs( effectName )) - { - return proj->OnEffect( effectFlags, (*effects)[i] ); + EffectArray *effects = EffectManager::Get().GetEffects(effectFlags); + if (effects) { + for(i=0; iGetCount(); i++) { + wxString effectName = (*effects)[i]->GetEffectName(); + if( Str.IsSameAs( effectName )) + { + result = proj->OnEffect( effectFlags, (*effects)[i] ); + break; + } } + delete effects; } - return false; + return result; } void CommandManager::GetCategories(wxArrayString &cats)