From b8ce7f61252762c5bdc78ec93f8a3418911eb684 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Thu, 28 May 2015 09:57:59 -0500 Subject: [PATCH] Fix for bug #981 --- lib-src/mod-nyq-bench/NyqBench.cpp | 13 +++++++------ lib-src/mod-nyq-bench/NyqBench.h | 0 lib-src/mod-nyq-bench/mod-nyq-bench.vcxproj | 4 ++-- src/PluginManager.cpp | 12 ++++++++++++ src/PluginManager.h | 1 + src/effects/EffectManager.cpp | 18 +++++++++++++++--- src/effects/EffectManager.h | 5 +++-- src/effects/nyquist/Nyquist.cpp | 11 ++++++----- 8 files changed, 46 insertions(+), 18 deletions(-) mode change 100644 => 100755 lib-src/mod-nyq-bench/NyqBench.cpp mode change 100644 => 100755 lib-src/mod-nyq-bench/NyqBench.h mode change 100644 => 100755 src/effects/EffectManager.cpp mode change 100644 => 100755 src/effects/EffectManager.h mode change 100644 => 100755 src/effects/nyquist/Nyquist.cpp diff --git a/lib-src/mod-nyq-bench/NyqBench.cpp b/lib-src/mod-nyq-bench/NyqBench.cpp old mode 100644 new mode 100755 index 75902922d..fb7be9689 --- a/lib-src/mod-nyq-bench/NyqBench.cpp +++ b/lib-src/mod-nyq-bench/NyqBench.cpp @@ -689,10 +689,6 @@ NyqBench::NyqBench(wxWindow * parent) mScript = NULL; mOutput = NULL; - // No need to delete...EffectManager will do it - mEffect = new NyquistEffect(wxT("===nyquistworker===")); - EffectManager::Get().RegisterEffect(mEffect); - mPath = gPrefs->Read(wxT("NyqBench/Path"), wxEmptyString); mAutoLoad = (gPrefs->Read(wxT("NyqBench/AutoLoad"), 0L) != 0); mAutoWrap = (gPrefs->Read(wxT("NyqBench/AutoWrap"), true) != 0); @@ -1353,6 +1349,10 @@ void NyqBench::OnLargeIcons(wxCommandEvent & e) void NyqBench::OnGo(wxCommandEvent & e) { + // No need to delete...EffectManager will do it + mEffect = new NyquistEffect(wxT("Nyquist Effect Workbench")); + const PluginID & ID = EffectManager::Get().RegisterEffect(mEffect); + mEffect->SetCommand(mScript->GetValue()); mEffect->RedirectOutput(); @@ -1366,14 +1366,15 @@ void NyqBench::OnGo(wxCommandEvent & e) mRunning = true; UpdateWindowUI(); - const PluginID & id = EffectManager::Get().GetEffectByIdentifier(mEffect->GetSymbol()); - p->OnEffect(id); + p->OnEffect(ID); mRunning = false; UpdateWindowUI(); } Raise(); + + EffectManager::Get().UnregisterEffect(ID); } void NyqBench::OnStop(wxCommandEvent & e) diff --git a/lib-src/mod-nyq-bench/NyqBench.h b/lib-src/mod-nyq-bench/NyqBench.h old mode 100644 new mode 100755 diff --git a/lib-src/mod-nyq-bench/mod-nyq-bench.vcxproj b/lib-src/mod-nyq-bench/mod-nyq-bench.vcxproj index bcca17d2b..fd6b4ec71 100755 --- a/lib-src/mod-nyq-bench/mod-nyq-bench.vcxproj +++ b/lib-src/mod-nyq-bench/mod-nyq-bench.vcxproj @@ -66,7 +66,7 @@ audacity.lib;wxbase28ud.lib;wxbase28ud_net.lib;wxmsw28ud_adv.lib;wxmsw28ud_core.lib;wxmsw28ud_html.lib;wxpngd.lib;wxzlibd.lib;wxjpegd.lib;wxtiffd.lib;%(AdditionalDependencies) - $(OutDir)modules\$(ProjectName).dll + ..\..\win\$(ConfigurationName)\modules\$(ProjectName).dll ..\..\win/$(Configuration);$(WXWIN)\lib\vc_dll;%(AdditionalLibraryDirectories) true Windows @@ -91,7 +91,7 @@ copy "$(TargetPath)" "%25dest%25" audacity.lib;wxbase28u.lib;wxbase28u_net.lib;wxmsw28u_adv.lib;wxmsw28u_core.lib;wxmsw28u_html.lib;wxpng.lib;wxzlib.lib;wxjpeg.lib;wxtiff.lib;%(AdditionalDependencies) - $(OutDir)modules\$(ProjectName).dll + ..\..\win\$(ConfigurationName)\modules\$(ProjectName).dll ../../win/$(Configuration);$(WXWIN)\lib\vc_dll;%(AdditionalLibraryDirectories) true Windows diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 2b3615d6e..93fdd57a5 100755 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -2201,6 +2201,18 @@ const PluginID & PluginManager::RegisterPlugin(EffectIdentInterface *effect) return plug.GetID(); } +// Here solely for the purpose of Nyquist Workbench until +// a better solution is devised. +void PluginManager::UnregisterPlugin(const PluginID & ID) +{ + if (mPlugins.find(ID) == mPlugins.end()) + { + return; + } + + mPlugins.erase(ID); +} + int PluginManager::GetPluginCount(PluginType type) { int num = 0; diff --git a/src/PluginManager.h b/src/PluginManager.h index 6d7242fb9..35e00fd40 100755 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -262,6 +262,7 @@ public: // Here solely for the purpose of Nyquist Workbench until // a better solution is devised. const PluginID & RegisterPlugin(EffectIdentInterface *effect); + void UnregisterPlugin(const PluginID & ID); private: void Load(); diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp old mode 100644 new mode 100755 index 10b75f2f8..a8ff6673a --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -65,10 +65,22 @@ EffectManager::~EffectManager() // Here solely for the purpose of Nyquist Workbench until // a better solution is devised. -void EffectManager::RegisterEffect(Effect *f) +const PluginID & EffectManager::RegisterEffect(Effect *f) { - // This will go away after all effects have been converted - mEffects[PluginManager::Get().RegisterPlugin(f)] = f; + const PluginID & ID = PluginManager::Get().RegisterPlugin(f); + + mEffects[ID] = f; + + return ID; +} + +// Here solely for the purpose of Nyquist Workbench until +// a better solution is devised. +void EffectManager::UnregisterEffect(const PluginID & ID) +{ + PluginID id = ID; + PluginManager::Get().UnregisterPlugin(id); + mEffects.erase(id); } bool EffectManager::DoEffect(const PluginID & ID, diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h old mode 100644 new mode 100755 index 1eb3bd8e4..5852d674c --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -56,10 +56,11 @@ public: EffectManager(); virtual ~EffectManager(); - /** Register an effect so it can be executed. */ + /** (Un)Register an effect so it can be executed. */ // Here solely for the purpose of Nyquist Workbench until // a better solution is devised. - void RegisterEffect(Effect *f); + const PluginID & RegisterEffect(Effect *f); + void UnregisterEffect(const PluginID & ID); /** Run an effect given the plugin ID */ // Returns true on success. Will only operate on tracks that diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp old mode 100644 new mode 100755 index 60ea6b87a..2685b92ad --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -150,11 +150,6 @@ NyquistEffect::~NyquistEffect() { } -void NyquistEffect::RedirectOutput() -{ - wxFAIL_MSG(XO("JKC: This function used to exist. Have a look in SVN and see if you can find it") ); -} - // IdentInterface implementation wxString NyquistEffect::GetPath() @@ -1180,6 +1175,12 @@ wxArrayString NyquistEffect::ParseChoice(const NyqControl & ctrl) return choices; } + +void NyquistEffect::RedirectOutput() +{ + mRedirectOutput = true; +} + void NyquistEffect::SetCommand(wxString cmd) { mExternal = true;