From 1e3ab82a011268bc0d93d0496840d950f75cc15b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 19 Aug 2017 06:45:23 -0400 Subject: [PATCH] Effect commands store PluginID in CommandEntry parameter, not functor --- src/Menus.cpp | 8 ++++---- src/commands/CommandFunctors.h | 13 +++++-------- src/commands/CommandManager.cpp | 5 +++-- src/commands/CommandManager.h | 3 ++- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index a231ae3c2..eb1ffa638 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -1875,9 +1875,9 @@ void AudacityProject::AddEffectMenuItemGroup(CommandManager *c, wxString item = PluginManager::Get().GetPlugin(plugs[i])->GetPath(); c->AddItem(item, item, - FNS(OnEffect, plugs[i]), + FN(OnEffect), flags[i], - flags[i]); + flags[i], plugs[i]); i++; } @@ -1888,9 +1888,9 @@ void AudacityProject::AddEffectMenuItemGroup(CommandManager *c, { c->AddItem(names[i], names[i], - FNS(OnEffect, plugs[i]), + FN(OnEffect), flags[i], - flags[i]); + flags[i], plugs[i]); } if (max > 0) diff --git a/src/commands/CommandFunctors.h b/src/commands/CommandFunctors.h index 4fdfcf550..2611485fb 100644 --- a/src/commands/CommandFunctors.h +++ b/src/commands/CommandFunctors.h @@ -127,15 +127,14 @@ template class PluginFunctor final : public CommandFunctor { public: - explicit PluginFunctor(OBJ *This, const PluginID &id, audCommandPluginFunction pfn) - : mPluginID{ id }, mThis{ This }, mCommandPluginFunction{ pfn } {} + explicit PluginFunctor(OBJ *This, audCommandPluginFunction pfn) + : mThis{ This }, mCommandPluginFunction{ pfn } {} void operator () (const CommandContext &context) override { (mThis->*mCommandPluginFunction) - (mPluginID, + (context.parameter, 0 // AudacityProject::OnEffectFlags::kNone ); } private: - const PluginID mPluginID; OBJ *const mThis; const audCommandPluginFunction mCommandPluginFunction; }; @@ -162,15 +161,13 @@ inline CommandFunctorPointer MakeFunctor(OBJ *This, { return CommandFunctorPointer{ safenew ListFunctor{ This, pfn } }; } template -inline CommandFunctorPointer MakeFunctor(OBJ *This, const PluginID &id, +inline CommandFunctorPointer MakeFunctor(OBJ *This, audCommandPluginFunction pfn) -{ return CommandFunctorPointer{ safenew PluginFunctor{ This, id, pfn } }; } +{ return CommandFunctorPointer{ safenew PluginFunctor{ This, pfn } }; } // Now define the macro abbreviations that call the factory #define FNT(OBJ, This, X) (MakeFunctor(This, X )) -#define FNTS(OBJ, This, X, S) (MakeFunctor(This, (S), X )) #define FN(X) FNT(AudacityProject, this, & AudacityProject :: X) -#define FNS(X, S) FNTS(AudacityProject, this, & AudacityProject :: X, S) #endif diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index caa88b7ab..03302106f 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -783,9 +783,10 @@ void CommandManager::AddItem(const wxChar *name, const wxChar *label, const CommandFunctorPointer &callback, CommandFlag flags, - CommandMask mask) + CommandMask mask, + const CommandParameter ¶meter) { - AddItem(name, label, callback, wxT(""), flags, mask); + AddItem(name, label, callback, wxT(""), flags, mask, -1, parameter); } void CommandManager::AddItem(const wxChar *name, diff --git a/src/commands/CommandManager.h b/src/commands/CommandManager.h index 44f927154..c4561f76a 100644 --- a/src/commands/CommandManager.h +++ b/src/commands/CommandManager.h @@ -149,7 +149,8 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler const wxChar *label, const CommandFunctorPointer &callback, CommandFlag flags = NoFlagsSpecifed, - CommandMask mask = NoFlagsSpecifed); + CommandMask mask = NoFlagsSpecifed, + const CommandParameter ¶meter = {}); void AddItem(const wxChar *name, const wxChar *label_in,