1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-24 00:00:06 +02:00

Use unique_ptr more properly in the fix for building mod-nyq-bench

This commit is contained in:
Paul Licameli 2016-10-02 09:46:48 -04:00
parent f4d38476a6
commit 09a3854256
2 changed files with 25 additions and 6 deletions

View File

@ -502,7 +502,8 @@ wxMenuBar * CommandManager::CurrentMenuBar() const
///
void CommandManager::BeginMenu(const wxString & tName)
{
mCurrentMenu = std::make_unique<wxMenu>();
uCurrentMenu = std::make_unique<wxMenu>();
mCurrentMenu = uCurrentMenu.get();
mCurrentMenuName = tName;
}
@ -515,7 +516,9 @@ void CommandManager::EndMenu()
// Add the menu to the menubar after all menu items have been
// added to the menu to allow OSX to rearrange special menu
// items like Preferences, About, and Quit.
CurrentMenuBar()->Append(mCurrentMenu.release(), mCurrentMenuName);
wxASSERT(uCurrentMenu);
CurrentMenuBar()->Append(uCurrentMenu.release(), mCurrentMenuName);
mCurrentMenu = nullptr;
mCurrentMenuName = COMMAND;
}
@ -575,7 +578,7 @@ wxMenu * CommandManager::CurrentMenu() const
if(!tmpCurrentSubMenu)
{
return mCurrentMenu.get();
return mCurrentMenu;
}
return tmpCurrentSubMenu;
@ -583,12 +586,22 @@ wxMenu * CommandManager::CurrentMenu() const
void CommandManager::SetCurrentMenu(wxMenu * menu)
{
mCurrentMenu.reset(menu);
// uCurrentMenu ought to be null in correct usage
wxASSERT(!uCurrentMenu);
// Make sure of it anyway
uCurrentMenu.reset();
mCurrentMenu = menu;
}
void CommandManager::ClearCurrentMenu()
{
mCurrentMenu.release();
// uCurrentMenu ought to be null in correct usage
wxASSERT(!uCurrentMenu);
// Make sure of it anyway
uCurrentMenu.reset();
mCurrentMenu = nullptr;
}
///

View File

@ -112,6 +112,8 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
std::unique_ptr<wxMenuBar> AddMenuBar(const wxString & sMenu);
// You may either called SetCurrentMenu later followed by ClearCurrentMenu,
// or else BeginMenu followed by EndMenu. Don't mix them.
void BeginMenu(const wxString & tName);
void EndMenu();
@ -198,6 +200,9 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
void Enable(const wxString &name, bool enabled);
void Check(const wxString &name, bool checked);
void Modify(const wxString &name, const wxString &newLabel);
// You may either called SetCurrentMenu later followed by ClearCurrentMenu,
// or else BeginMenu followed by EndMenu. Don't mix them.
void SetCurrentMenu(wxMenu * menu);
void ClearCurrentMenu();
@ -318,7 +323,8 @@ private:
bool mbSeparatorAllowed; // false at the start of a menu and immediately after a separator.
wxString mCurrentMenuName;
std::unique_ptr<wxMenu> mCurrentMenu;
std::unique_ptr<wxMenu> uCurrentMenu;
wxMenu *mCurrentMenu {};
CommandFlag mDefaultFlags;
CommandMask mDefaultMask;