mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 08:09:32 +02:00
Reviewed allocations of wxMenuBar items.
This commit is contained in:
parent
af16636fe2
commit
cf3daebff6
@ -1406,10 +1406,14 @@ bool AudacityApp::OnInit()
|
|||||||
fileMenu->Append(wxID_ABOUT, _("&About Audacity..."));
|
fileMenu->Append(wxID_ABOUT, _("&About Audacity..."));
|
||||||
fileMenu->Append(wxID_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,"));
|
fileMenu->Append(wxID_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,"));
|
||||||
|
|
||||||
wxMenuBar *menuBar = new wxMenuBar();
|
{
|
||||||
|
auto menuBar = std::make_unique<wxMenuBar>();
|
||||||
menuBar->Append(fileMenu, _("&File"));
|
menuBar->Append(fileMenu, _("&File"));
|
||||||
|
|
||||||
wxMenuBar::MacSetCommonMenuBar(menuBar);
|
// PRL: Are we sure wxWindows will not leak this menuBar?
|
||||||
|
// The online documentation is not explicit.
|
||||||
|
wxMenuBar::MacSetCommonMenuBar(menuBar.release());
|
||||||
|
}
|
||||||
|
|
||||||
mRecentFiles->UseMenu(recentMenu);
|
mRecentFiles->UseMenu(recentMenu);
|
||||||
mRecentFiles->AddFilesToMenu(recentMenu);
|
mRecentFiles->AddFilesToMenu(recentMenu);
|
||||||
|
@ -328,7 +328,9 @@ void AudacityProject::CreateMenusAndCommands()
|
|||||||
wxArrayString names;
|
wxArrayString names;
|
||||||
wxArrayInt indices;
|
wxArrayInt indices;
|
||||||
|
|
||||||
wxMenuBar *menubar = c->AddMenuBar(wxT("appmenu"));
|
{
|
||||||
|
auto menubar = c->AddMenuBar(wxT("appmenu"));
|
||||||
|
wxASSERT(menubar);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// File menu
|
// File menu
|
||||||
@ -1099,7 +1101,8 @@ void AudacityProject::CreateMenusAndCommands()
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SetMenuBar(menubar);
|
SetMenuBar(menubar.release());
|
||||||
|
}
|
||||||
|
|
||||||
c->AddGlobalCommand(wxT("PrevWindow"), _("Move backward thru active windows"), FN(PrevWindow), wxT("Alt+Shift+F6"));
|
c->AddGlobalCommand(wxT("PrevWindow"), _("Move backward thru active windows"), FN(PrevWindow), wxT("Alt+Shift+F6"));
|
||||||
c->AddGlobalCommand(wxT("NextWindow"), _("Move forward thru active windows"), FN(NextWindow), wxT("Alt+F6"));
|
c->AddGlobalCommand(wxT("NextWindow"), _("Move forward thru active windows"), FN(NextWindow), wxT("Alt+F6"));
|
||||||
@ -1628,9 +1631,11 @@ void AudacityProject::RebuildMenuBar()
|
|||||||
|
|
||||||
// Delete the menus, since we will soon recreate them.
|
// Delete the menus, since we will soon recreate them.
|
||||||
// Rather oddly, the menus don't vanish as a result of doing this.
|
// Rather oddly, the menus don't vanish as a result of doing this.
|
||||||
wxMenuBar *menuBar = GetMenuBar();
|
{
|
||||||
|
std::unique_ptr<wxMenuBar> menuBar{ GetMenuBar() };
|
||||||
DetachMenuBar();
|
DetachMenuBar();
|
||||||
delete menuBar;
|
// menuBar gets deleted here
|
||||||
|
}
|
||||||
|
|
||||||
mCommandManager.PurgeData();
|
mCommandManager.PurgeData();
|
||||||
|
|
||||||
|
@ -672,20 +672,20 @@ ShuttleGuiBase & ShuttleGuiBase::Prop( int iProp )
|
|||||||
|
|
||||||
wxMenuBar * ShuttleGuiBase::AddMenuBar( )
|
wxMenuBar * ShuttleGuiBase::AddMenuBar( )
|
||||||
{
|
{
|
||||||
mpMenuBar = new wxMenuBar( );
|
auto menuBar = std::make_unique<wxMenuBar>();
|
||||||
|
mpMenuBar = menuBar.get();
|
||||||
|
|
||||||
wxFrame * pFrame = (wxFrame*)mpParent;
|
wxFrame * pFrame = (wxFrame*)mpParent;
|
||||||
pFrame->SetThemeEnabled( true );
|
pFrame->SetThemeEnabled( true );
|
||||||
mpMenuBar->SetThemeEnabled( true );
|
mpMenuBar->SetThemeEnabled( true );
|
||||||
pFrame->SetMenuBar(mpMenuBar);
|
pFrame->SetMenuBar(menuBar.release());
|
||||||
|
|
||||||
return mpMenuBar;
|
return mpMenuBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu * ShuttleGuiBase::AddMenu( const wxString & Title )
|
wxMenu * ShuttleGuiBase::AddMenu( const wxString & Title )
|
||||||
{
|
{
|
||||||
mpMenu = new wxMenu;
|
mpMenuBar->Append( (mpMenu = safenew wxMenu), Title );
|
||||||
mpMenuBar->Append( mpMenu, Title );
|
|
||||||
return mpMenu;
|
return mpMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,15 +433,17 @@ void CommandManager::PurgeData()
|
|||||||
/// Makes a NEW menubar for placement on the top of a project
|
/// Makes a NEW menubar for placement on the top of a project
|
||||||
/// Names it according to the passed-in string argument.
|
/// Names it according to the passed-in string argument.
|
||||||
///
|
///
|
||||||
/// If the menubar already exists, simply returns it.
|
/// If the menubar already exists, that's unexpected.
|
||||||
wxMenuBar *CommandManager::AddMenuBar(const wxString & sMenu)
|
std::unique_ptr<wxMenuBar> CommandManager::AddMenuBar(const wxString & sMenu)
|
||||||
{
|
{
|
||||||
wxMenuBar *menuBar = GetMenuBar(sMenu);
|
wxMenuBar *menuBar = GetMenuBar(sMenu);
|
||||||
if (menuBar)
|
if (menuBar) {
|
||||||
return menuBar;
|
wxASSERT(false);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
const auto result = new wxMenuBar{};
|
auto result = std::make_unique<wxMenuBar>();
|
||||||
mMenuBarList.emplace_back(sMenu, result);
|
mMenuBarList.emplace_back(sMenu, result.get());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -491,7 +493,7 @@ void CommandManager::BeginMenu(const wxString & tName)
|
|||||||
///
|
///
|
||||||
void CommandManager::EndMenu()
|
void CommandManager::EndMenu()
|
||||||
{
|
{
|
||||||
// Add the menu to the menubard after all menu items have been
|
// Add the menu to the menubar after all menu items have been
|
||||||
// added to the menu to allow OSX to rearrange special menu
|
// added to the menu to allow OSX to rearrange special menu
|
||||||
// items like Preferences, About, and Quit.
|
// items like Preferences, About, and Quit.
|
||||||
CurrentMenuBar()->Append(mCurrentMenu, mCurrentMenuName);
|
CurrentMenuBar()->Append(mCurrentMenu, mCurrentMenuName);
|
||||||
|
@ -40,7 +40,7 @@ struct MenuBarListEntry
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
wxString name;
|
wxString name;
|
||||||
wxMenuBar *menubar;
|
wxMenuBar *menubar; // This structure does not assume memory ownership!
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubMenuListEntry
|
struct SubMenuListEntry
|
||||||
@ -109,7 +109,7 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
|||||||
// Creating menus and adding commands
|
// Creating menus and adding commands
|
||||||
//
|
//
|
||||||
|
|
||||||
wxMenuBar *AddMenuBar(const wxString & sMenu);
|
std::unique_ptr<wxMenuBar> AddMenuBar(const wxString & sMenu);
|
||||||
|
|
||||||
void BeginMenu(const wxString & tName);
|
void BeginMenu(const wxString & tName);
|
||||||
void EndMenu();
|
void EndMenu();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user