From 19bf094893b04c933154c269917c4a75c33647c5 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 27 Feb 2019 12:57:21 -0500 Subject: [PATCH] Change CommandManager terminology: "Numeric id" not just "Id" ... ... because I will use CommandId for string identifiers instead, and those are the really persistent identification --- src/commands/CommandManager.cpp | 12 ++++++------ src/commands/CommandManager.h | 8 +++++--- src/commands/GetInfoCommand.cpp | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index f3373d2d3..86c4c4fc1 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -577,7 +577,7 @@ void CommandManager::PurgeData() mCommandNameHash.clear(); mCommandKeyHash.clear(); - mCommandIDHash.clear(); + mCommandNumericIDHash.clear(); mCurrentMenuName = COMMAND; mCurrentID = 17000; @@ -1064,7 +1064,7 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn, // New variable CommandListEntry *entry = &*mCommandList.back(); - mCommandIDHash[entry->id] = entry; + mCommandNumericIDHash[entry->id] = entry; #if defined(__WXDEBUG__) prev = mCommandNameHash[entry->name]; @@ -1192,7 +1192,7 @@ void CommandManager::Enable(CommandListEntry *entry, bool enabled) // This menu item is not necessarily in the same menu, because // multi-items can be spread across multiple sub menus - CommandListEntry *multiEntry = mCommandIDHash[ID]; + CommandListEntry *multiEntry = mCommandNumericIDHash[ID]; if (multiEntry) { wxMenuItem *item = multiEntry->menu->FindItem(ID); @@ -1554,7 +1554,7 @@ bool CommandManager::HandleCommandEntry(const CommandListEntry * entry, #include "../prefs/KeyConfigPrefs.h" bool CommandManager::HandleMenuID(int id, CommandFlag flags, CommandMask mask) { - CommandListEntry *entry = mCommandIDHash[id]; + CommandListEntry *entry = mCommandNumericIDHash[id]; #ifdef EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS if (::wxGetMouseState().ShiftDown()) { @@ -1728,9 +1728,9 @@ void CommandManager::GetAllCommandData( } } -CommandID CommandManager::GetNameFromID(int id) +CommandID CommandManager::GetNameFromNumericID(int id) { - CommandListEntry *entry = mCommandIDHash[id]; + CommandListEntry *entry = mCommandNumericIDHash[id]; if (!entry) return {}; return entry->name; diff --git a/src/commands/CommandManager.h b/src/commands/CommandManager.h index c76ea5876..7653ebf08 100644 --- a/src/commands/CommandManager.h +++ b/src/commands/CommandManager.h @@ -95,7 +95,7 @@ using CommandList = std::vector>; using CommandKeyHash = std::unordered_map; using CommandNameHash = std::unordered_map; -using CommandIDHash = std::unordered_map; +using CommandNumericIDHash = std::unordered_map; class AudacityProject; class CommandContext; @@ -253,7 +253,9 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler #endif bool includeMultis); - CommandID GetNameFromID( int id ); + // Each command is assigned a numerical ID for use in wxMenu and wxEvent, + // which need not be the same across platforms or sessions + CommandID GetNameFromNumericID( int id ); wxString GetLabelFromName(const CommandID &name); wxString GetPrefixedLabelFromName(const CommandID &name); @@ -372,7 +374,7 @@ private: CommandList mCommandList; CommandNameHash mCommandNameHash; CommandKeyHash mCommandKeyHash; - CommandIDHash mCommandIDHash; + CommandNumericIDHash mCommandNumericIDHash; int mCurrentID; int mXMLKeysRead; diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index dbab20b7c..6b0cc4dc6 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -653,7 +653,7 @@ void GetInfoCommand::ExploreMenu( const CommandContext &context, wxMenu * pMenu, for (size_t lndx = 0; lndx < lcnt; lndx++) { item = list.Item(lndx)->GetData(); Label = item->GetItemLabelText(); - Name = pMan->GetNameFromID( item->GetId() ); + Name = pMan->GetNameFromNumericID( item->GetId() ); Accel = item->GetItemLabel(); if( Accel.Contains("\t") ) Accel = Accel.AfterLast('\t');