mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-21 14:02:57 +02:00
Don't hold a dangling pointer to a menu bar in CommandManager
This commit is contained in:
@@ -597,17 +597,17 @@ wxMenuBar * CommandManager::CurrentMenuBar() const
|
||||
}
|
||||
|
||||
///
|
||||
/// Swap the last two menu bars in the list,
|
||||
/// to make the previous menu bar 'current' again.
|
||||
/// Typically used to switch back and forth
|
||||
/// between adding to a hidden menu bar and
|
||||
/// adding to one that is visible,
|
||||
/// adding to one that is visible
|
||||
///
|
||||
void CommandManager::SwapMenuBars()
|
||||
void CommandManager::PopMenuBar()
|
||||
{
|
||||
int l = mMenuBarList.size();
|
||||
wxASSERT(l >= 2);
|
||||
std::swap(mMenuBarList[l - 2], mMenuBarList[l - 1]);
|
||||
auto iter = mMenuBarList.end();
|
||||
if ( iter != mMenuBarList.begin() )
|
||||
mMenuBarList.erase( --iter );
|
||||
else
|
||||
wxASSERT( false );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -40,7 +40,7 @@ struct MenuBarListEntry
|
||||
{}
|
||||
|
||||
wxString name;
|
||||
wxMenuBar *menubar; // This structure does not assume memory ownership!
|
||||
wxWeakRef<wxMenuBar> menubar; // This structure does not assume memory ownership!
|
||||
};
|
||||
|
||||
struct SubMenuListEntry
|
||||
@@ -211,7 +211,7 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
|
||||
const wxChar *accel,
|
||||
CommandFlag flags);
|
||||
|
||||
void SwapMenuBars();
|
||||
void PopMenuBar();
|
||||
void SetOccultCommands( bool bOccult);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user