mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +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_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,"));
|
||||
|
||||
wxMenuBar *menuBar = new wxMenuBar();
|
||||
menuBar->Append(fileMenu, _("&File"));
|
||||
{
|
||||
auto menuBar = std::make_unique<wxMenuBar>();
|
||||
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->AddFilesToMenu(recentMenu);
|
||||
|
1073
src/Menus.cpp
1073
src/Menus.cpp
File diff suppressed because it is too large
Load Diff
@ -672,20 +672,20 @@ ShuttleGuiBase & ShuttleGuiBase::Prop( int iProp )
|
||||
|
||||
wxMenuBar * ShuttleGuiBase::AddMenuBar( )
|
||||
{
|
||||
mpMenuBar = new wxMenuBar( );
|
||||
auto menuBar = std::make_unique<wxMenuBar>();
|
||||
mpMenuBar = menuBar.get();
|
||||
|
||||
wxFrame * pFrame = (wxFrame*)mpParent;
|
||||
pFrame->SetThemeEnabled( true );
|
||||
mpMenuBar->SetThemeEnabled( true );
|
||||
pFrame->SetMenuBar(mpMenuBar);
|
||||
pFrame->SetMenuBar(menuBar.release());
|
||||
|
||||
return mpMenuBar;
|
||||
}
|
||||
|
||||
wxMenu * ShuttleGuiBase::AddMenu( const wxString & Title )
|
||||
{
|
||||
mpMenu = new wxMenu;
|
||||
mpMenuBar->Append( mpMenu, Title );
|
||||
mpMenuBar->Append( (mpMenu = safenew wxMenu), Title );
|
||||
return mpMenu;
|
||||
}
|
||||
|
||||
|
@ -433,15 +433,17 @@ void CommandManager::PurgeData()
|
||||
/// Makes a NEW menubar for placement on the top of a project
|
||||
/// Names it according to the passed-in string argument.
|
||||
///
|
||||
/// If the menubar already exists, simply returns it.
|
||||
wxMenuBar *CommandManager::AddMenuBar(const wxString & sMenu)
|
||||
/// If the menubar already exists, that's unexpected.
|
||||
std::unique_ptr<wxMenuBar> CommandManager::AddMenuBar(const wxString & sMenu)
|
||||
{
|
||||
wxMenuBar *menuBar = GetMenuBar(sMenu);
|
||||
if (menuBar)
|
||||
return menuBar;
|
||||
if (menuBar) {
|
||||
wxASSERT(false);
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto result = new wxMenuBar{};
|
||||
mMenuBarList.emplace_back(sMenu, result);
|
||||
auto result = std::make_unique<wxMenuBar>();
|
||||
mMenuBarList.emplace_back(sMenu, result.get());
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -491,7 +493,7 @@ void CommandManager::BeginMenu(const wxString & tName)
|
||||
///
|
||||
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
|
||||
// items like Preferences, About, and Quit.
|
||||
CurrentMenuBar()->Append(mCurrentMenu, mCurrentMenuName);
|
||||
|
@ -40,7 +40,7 @@ struct MenuBarListEntry
|
||||
{}
|
||||
|
||||
wxString name;
|
||||
wxMenuBar *menubar;
|
||||
wxMenuBar *menubar; // This structure does not assume memory ownership!
|
||||
};
|
||||
|
||||
struct SubMenuListEntry
|
||||
@ -109,7 +109,7 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
||||
// Creating menus and adding commands
|
||||
//
|
||||
|
||||
wxMenuBar *AddMenuBar(const wxString & sMenu);
|
||||
std::unique_ptr<wxMenuBar> AddMenuBar(const wxString & sMenu);
|
||||
|
||||
void BeginMenu(const wxString & tName);
|
||||
void EndMenu();
|
||||
|
Loading…
x
Reference in New Issue
Block a user