Fix memory leak and push menu change to other apps.
Fixes: lp:1761848 * https://bugs.launchpad.net/kicad/+bug/1761848
This commit is contained in:
parent
0bd5cc4470
commit
baef22df9a
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue