From 13713aab67b13061d14cf4ee4b96348c0974a6c6 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 11 May 2019 18:10:21 -0400 Subject: [PATCH] Remove nullary overload of AudacityCommand::Apply... ... which by default used GetActiveProject(); do that call instead at a higher level; so that AudacityCommand.cpp does not depend on Project.cpp. We lose the override of that for CompareAudioCommand which just did nothing. But in fact this overload of the base class method could only be used by EffectUIHost constructed from a command, which never happened: it was only ever constructed from effects. This frees two files from dependency cycles --- src/commands/AudacityCommand.cpp | 7 ------- src/commands/AudacityCommand.h | 3 +-- src/commands/CompareAudioCommand.cpp | 4 ---- src/commands/CompareAudioCommand.h | 1 - src/effects/Effect.cpp | 4 +++- 5 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/commands/AudacityCommand.cpp b/src/commands/AudacityCommand.cpp index 7ed08d232..89e6dbfcf 100644 --- a/src/commands/AudacityCommand.cpp +++ b/src/commands/AudacityCommand.cpp @@ -37,7 +37,6 @@ ShuttleGui. #include "audacity/ConfigInterface.h" -#include "../Project.h" #include "../Shuttle.h" #include "../ShuttleGui.h" #include "../widgets/ProgressDialog.h" @@ -87,12 +86,6 @@ VendorSymbol AudacityCommand::GetVendor(){ return XO("Audacity");} wxString AudacityCommand::GetVersion(){ return AUDACITY_VERSION_STRING;} -bool AudacityCommand::Apply() { - AudacityProject * pProj = GetActiveProject(); - const CommandContext context( *pProj ); - return Apply( context ); -}; - bool AudacityCommand::Init(){ if( !mNeedsInit ) return true; diff --git a/src/commands/AudacityCommand.h b/src/commands/AudacityCommand.h index d454c337d..e26c0fb06 100644 --- a/src/commands/AudacityCommand.h +++ b/src/commands/AudacityCommand.h @@ -69,8 +69,7 @@ class AUDACITY_DLL_API AudacityCommand /* not final */ : public wxEvtHandler, virtual bool IsBatchProcessing(){ return mIsBatch;} virtual void SetBatchProcessing(bool start){ mIsBatch = start;}; - virtual bool Apply(const CommandContext & WXUNUSED(context) ) {return false;}; - virtual bool Apply(); // redirects to the command context version. + virtual bool Apply(const CommandContext & WXUNUSED(context) ) {return false;}; bool ShowInterface(wxWindow *parent, bool forceModal = false); virtual void SetHostUI(EffectUIHostInterface * WXUNUSED(host)){;}; diff --git a/src/commands/CompareAudioCommand.cpp b/src/commands/CompareAudioCommand.cpp index 70aaca13c..c3502b85b 100644 --- a/src/commands/CompareAudioCommand.cpp +++ b/src/commands/CompareAudioCommand.cpp @@ -46,10 +46,6 @@ bool CompareAudioCommand::DefineParams( ShuttleParams & S ){ return true; } -bool CompareAudioCommand::Apply(){ - return true; -} - void CompareAudioCommand::PopulateOrExchange(ShuttleGui & S) { S.AddSpace(0, 5); diff --git a/src/commands/CompareAudioCommand.h b/src/commands/CompareAudioCommand.h index 01a350181..de51d88fd 100644 --- a/src/commands/CompareAudioCommand.h +++ b/src/commands/CompareAudioCommand.h @@ -33,7 +33,6 @@ public: wxString GetDescription() override {return _("Compares a range on two tracks.");}; bool DefineParams( ShuttleParams & S ) override; void PopulateOrExchange(ShuttleGui & S) override; - bool Apply() override; // AudacityCommand overrides wxString ManualPage() override {return wxT("Extra_Menu:_Scriptables_II#compare_Audio");}; diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 7d70cf45b..bd322748f 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -3322,7 +3322,9 @@ void EffectUIHost::OnApply(wxCommandEvent & evt) if( mEffect ) mEffect->Apply(); if( mCommand ) - mCommand->Apply(); + // PRL: I don't like the global and would rather pass *mProject! + // But I am preserving old behavior + mCommand->Apply( CommandContext{ *GetActiveProject() } ); } void EffectUIHost::DoCancel()