diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index a96e75d1ea..d378fb9713 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -42,18 +42,10 @@ */ void CVPCB_MAINFRAME::ReCreateMenuBar() { - // Create the current menubar if it does not yet exist - wxMenuBar* menuBar = GetMenuBar(); - - if( ! menuBar ) // Delete all menus - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); - - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); // Recreate all menus: @@ -117,11 +109,6 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() menuBar->Append( preferencesMenu, _( "&Preferences" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; } diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 5a426921f0..0b689f974e 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -70,19 +70,11 @@ static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu void SCH_EDIT_FRAME::ReCreateMenuBar() { - // Create and try to get the current menubar + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); wxString text; - wxMenuBar* menuBar = GetMenuBar(); - - if( !menuBar ) - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); - - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); // Recreate all menus: @@ -128,13 +120,8 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() menuBar->Append( preferencesMenu, _( "P&references" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; } diff --git a/eeschema/menubar_libedit.cpp b/eeschema/menubar_libedit.cpp index 3e1804a290..ccb11ca3a3 100644 --- a/eeschema/menubar_libedit.cpp +++ b/eeschema/menubar_libedit.cpp @@ -43,19 +43,11 @@ */ void LIB_EDIT_FRAME::ReCreateMenuBar() { - // Create and try to get the current menubar + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); wxString text; - wxMenuBar* menuBar = GetMenuBar(); - - if( !menuBar ) - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); - - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); // Recreate all menus: @@ -360,11 +352,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() menuBar->Append( preferencesMenu, _( "P&references" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; } diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index f276cf9cdf..be64896b42 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -158,21 +158,13 @@ void LIB_VIEW_FRAME::ReCreateVToolbar() // Virtual function void LIB_VIEW_FRAME::ReCreateMenuBar( void ) { - // Create and try to get the current menubar - wxMenuBar* menuBar = GetMenuBar(); - - if( !menuBar ) - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); - - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); + wxString text; // Recreate all menus: - wxString text; // Menu File: wxMenu* fileMenu = new wxMenu; @@ -237,11 +229,6 @@ void LIB_VIEW_FRAME::ReCreateMenuBar( void ) menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; } diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 83dea3ebe8..bfa7fd7f6e 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -40,20 +40,12 @@ void GERBVIEW_FRAME::ReCreateMenuBar() { - // Create and try to get the current menubar - wxMenuBar* menuBar = GetMenuBar(); + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); wxString text; - if( !menuBar ) - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); - - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); - // Recreate all menus: // Menu File: @@ -402,11 +394,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() menuBar->Append( miscellaneousMenu, _( "&Miscellaneous" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; } diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index ccf65e207a..8283bb4bf0 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -199,25 +199,16 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() m_manager_Hokeys_Descr = kicad_Manager_Hokeys_Descr; - // Create and try to get the current menubar - wxMenuBar* menuBar = GetMenuBar(); - - if( !menuBar ) - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); // Before deleting, remove the menus managed by m_fileHistory // (the file history will be updated when adding/removing files in history) if( openRecentMenu ) PgmTop().GetFileHistory().RemoveMenu( openRecentMenu ); - // Delete all existing menus - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); - // Recreate all menus: // Menu File: @@ -486,13 +477,8 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() menuBar->Append( preferencesMenu, _( "&Preferences" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; // Add the hotkey to the "show hotkey list" menu, because we do not have // a management of the keyboard keys in Kicad. diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index be44f09fdf..b5024fc5e4 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -40,29 +40,20 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() { + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); + wxString msg; static wxMenu* openRecentMenu; // Open Recent submenu, // static to remember this menu - // Create and try to get the current menubar - wxMenuBar* menuBar = GetMenuBar(); - - if( !menuBar ) - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); - // Before deleting, remove the menus managed by m_fileHistory // (the file history will be updated when adding/removing files in history if( openRecentMenu ) Kiface().GetFileHistory().RemoveMenu( openRecentMenu ); - // Delete all existing menus - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); - // Recreate all menus: // File Menu: @@ -246,11 +237,6 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() menuBar->Append( preferencesMenu, _( "P&references" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; } diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index c1dbb1baff..524eb19427 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -42,21 +42,13 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() { - // Create and try to get the current menubar - wxMenuBar* menuBar = GetMenuBar(); - - if( !menuBar ) - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); - - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); + wxString text; // Recreate all menus: - wxString text; // Menu File: wxMenu* fileMenu = new wxMenu; @@ -534,11 +526,6 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() menuBar->Append( prefs_menu, _( "P&references" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; } diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 6741255a72..2516bf5b64 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -83,8 +83,11 @@ static void prepareHelpMenu( wxMenu* aParentMenu ); void PCB_EDIT_FRAME::ReCreateMenuBar() { - wxString text; - wxMenuBar* menuBar = new wxMenuBar(); + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); + wxString text; // Recreate all menus: @@ -144,6 +147,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() menuBar->Append( helpMenu, _( "&Help" ) ); SetMenuBar( menuBar ); + delete oldMenuBar; #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) // Populate the Action Plugin sub-menu diff --git a/pcbnew/tool_footprint_viewer.cpp b/pcbnew/tool_footprint_viewer.cpp index 4294175cba..4a2a5f47bb 100644 --- a/pcbnew/tool_footprint_viewer.cpp +++ b/pcbnew/tool_footprint_viewer.cpp @@ -118,21 +118,13 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateVToolbar() // Virtual function void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar( void ) { - // Create and try to get the current menubar - wxMenuBar* menuBar = GetMenuBar(); - - if( !menuBar ) - menuBar = new wxMenuBar(); - - // Delete all existing menus so they can be rebuilt. - // This allows language changes of the menu text on the fly. - menuBar->Freeze(); - - while( menuBar->GetMenuCount() ) - delete menuBar->Remove( 0 ); + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); + wxString text; // Recreate all menus: - wxString text; // Menu File: wxMenu* fileMenu = new wxMenu; @@ -202,11 +194,6 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar( void ) menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - menuBar->Thaw(); - - // Associate the menu bar with the frame, if no previous menubar - if( GetMenuBar() == NULL ) - SetMenuBar( menuBar ); - else - menuBar->Refresh(); + SetMenuBar( menuBar ); + delete oldMenuBar; }