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()
|
void CVPCB_MAINFRAME::ReCreateMenuBar()
|
||||||
{
|
{
|
||||||
// Create the current menubar if it does not yet exist
|
// wxWidgets handles the Mac Application menu behind the scenes, but that means
|
||||||
wxMenuBar* menuBar = GetMenuBar();
|
// we always have to start from scratch with a new wxMenuBar.
|
||||||
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
||||||
if( ! menuBar ) // Delete all menus
|
wxMenuBar* menuBar = new wxMenuBar();
|
||||||
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:
|
// Recreate all menus:
|
||||||
|
|
||||||
|
@ -117,11 +109,6 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
|
||||||
menuBar->Append( preferencesMenu, _( "&Preferences" ) );
|
menuBar->Append( preferencesMenu, _( "&Preferences" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,19 +70,11 @@ static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::ReCreateMenuBar()
|
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;
|
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:
|
// Recreate all menus:
|
||||||
|
|
||||||
|
@ -128,13 +120,8 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
||||||
menuBar->Append( preferencesMenu, _( "P&references" ) );
|
menuBar->Append( preferencesMenu, _( "P&references" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,19 +43,11 @@
|
||||||
*/
|
*/
|
||||||
void LIB_EDIT_FRAME::ReCreateMenuBar()
|
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;
|
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:
|
// Recreate all menus:
|
||||||
|
|
||||||
|
@ -360,11 +352,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
menuBar->Append( preferencesMenu, _( "P&references" ) );
|
menuBar->Append( preferencesMenu, _( "P&references" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,21 +158,13 @@ void LIB_VIEW_FRAME::ReCreateVToolbar()
|
||||||
// Virtual function
|
// Virtual function
|
||||||
void LIB_VIEW_FRAME::ReCreateMenuBar( void )
|
void LIB_VIEW_FRAME::ReCreateMenuBar( void )
|
||||||
{
|
{
|
||||||
// Create and try to get the current menubar
|
// wxWidgets handles the Mac Application menu behind the scenes, but that means
|
||||||
wxMenuBar* menuBar = GetMenuBar();
|
// we always have to start from scratch with a new wxMenuBar.
|
||||||
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
||||||
if( !menuBar )
|
wxMenuBar* menuBar = new wxMenuBar();
|
||||||
menuBar = new wxMenuBar();
|
wxString text;
|
||||||
|
|
||||||
// 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:
|
// Recreate all menus:
|
||||||
wxString text;
|
|
||||||
|
|
||||||
// Menu File:
|
// Menu File:
|
||||||
wxMenu* fileMenu = new wxMenu;
|
wxMenu* fileMenu = new wxMenu;
|
||||||
|
@ -237,11 +229,6 @@ void LIB_VIEW_FRAME::ReCreateMenuBar( void )
|
||||||
menuBar->Append( viewMenu, _( "&View" ) );
|
menuBar->Append( viewMenu, _( "&View" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,20 +40,12 @@
|
||||||
|
|
||||||
void GERBVIEW_FRAME::ReCreateMenuBar()
|
void GERBVIEW_FRAME::ReCreateMenuBar()
|
||||||
{
|
{
|
||||||
// Create and try to get the current menubar
|
// wxWidgets handles the Mac Application menu behind the scenes, but that means
|
||||||
wxMenuBar* menuBar = GetMenuBar();
|
// we always have to start from scratch with a new wxMenuBar.
|
||||||
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
||||||
|
wxMenuBar* menuBar = new wxMenuBar();
|
||||||
wxString text;
|
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:
|
// Recreate all menus:
|
||||||
|
|
||||||
// Menu File:
|
// Menu File:
|
||||||
|
@ -402,11 +394,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
|
||||||
menuBar->Append( miscellaneousMenu, _( "&Miscellaneous" ) );
|
menuBar->Append( miscellaneousMenu, _( "&Miscellaneous" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
// Associate the menu bar with the frame, if no previous menubar
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,25 +199,16 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
||||||
|
|
||||||
m_manager_Hokeys_Descr = kicad_Manager_Hokeys_Descr;
|
m_manager_Hokeys_Descr = kicad_Manager_Hokeys_Descr;
|
||||||
|
|
||||||
// Create and try to get the current menubar
|
// wxWidgets handles the Mac Application menu behind the scenes, but that means
|
||||||
wxMenuBar* menuBar = GetMenuBar();
|
// we always have to start from scratch with a new wxMenuBar.
|
||||||
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
||||||
if( !menuBar )
|
wxMenuBar* menuBar = new wxMenuBar();
|
||||||
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
|
// Before deleting, remove the menus managed by m_fileHistory
|
||||||
// (the file history will be updated when adding/removing files in history)
|
// (the file history will be updated when adding/removing files in history)
|
||||||
if( openRecentMenu )
|
if( openRecentMenu )
|
||||||
PgmTop().GetFileHistory().RemoveMenu( openRecentMenu );
|
PgmTop().GetFileHistory().RemoveMenu( openRecentMenu );
|
||||||
|
|
||||||
// Delete all existing menus
|
|
||||||
while( menuBar->GetMenuCount() )
|
|
||||||
delete menuBar->Remove( 0 );
|
|
||||||
|
|
||||||
// Recreate all menus:
|
// Recreate all menus:
|
||||||
|
|
||||||
// Menu File:
|
// Menu File:
|
||||||
|
@ -486,13 +477,8 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
||||||
menuBar->Append( preferencesMenu, _( "&Preferences" ) );
|
menuBar->Append( preferencesMenu, _( "&Preferences" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
|
|
||||||
// Add the hotkey to the "show hotkey list" menu, because we do not have
|
// Add the hotkey to the "show hotkey list" menu, because we do not have
|
||||||
// a management of the keyboard keys in Kicad.
|
// a management of the keyboard keys in Kicad.
|
||||||
|
|
|
@ -40,29 +40,20 @@
|
||||||
|
|
||||||
void PL_EDITOR_FRAME::ReCreateMenuBar()
|
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;
|
wxString msg;
|
||||||
static wxMenu* openRecentMenu; // Open Recent submenu,
|
static wxMenu* openRecentMenu; // Open Recent submenu,
|
||||||
// static to remember this menu
|
// 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
|
// Before deleting, remove the menus managed by m_fileHistory
|
||||||
// (the file history will be updated when adding/removing files in history
|
// (the file history will be updated when adding/removing files in history
|
||||||
if( openRecentMenu )
|
if( openRecentMenu )
|
||||||
Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
|
Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
|
||||||
|
|
||||||
// Delete all existing menus
|
|
||||||
while( menuBar->GetMenuCount() )
|
|
||||||
delete menuBar->Remove( 0 );
|
|
||||||
|
|
||||||
// Recreate all menus:
|
// Recreate all menus:
|
||||||
|
|
||||||
// File Menu:
|
// File Menu:
|
||||||
|
@ -246,11 +237,6 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
|
||||||
menuBar->Append( preferencesMenu, _( "P&references" ) );
|
menuBar->Append( preferencesMenu, _( "P&references" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,21 +42,13 @@
|
||||||
|
|
||||||
void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
||||||
{
|
{
|
||||||
// Create and try to get the current menubar
|
// wxWidgets handles the Mac Application menu behind the scenes, but that means
|
||||||
wxMenuBar* menuBar = GetMenuBar();
|
// we always have to start from scratch with a new wxMenuBar.
|
||||||
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
||||||
if( !menuBar )
|
wxMenuBar* menuBar = new wxMenuBar();
|
||||||
menuBar = new wxMenuBar();
|
wxString text;
|
||||||
|
|
||||||
// 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:
|
// Recreate all menus:
|
||||||
wxString text;
|
|
||||||
|
|
||||||
// Menu File:
|
// Menu File:
|
||||||
wxMenu* fileMenu = new wxMenu;
|
wxMenu* fileMenu = new wxMenu;
|
||||||
|
@ -534,11 +526,6 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
||||||
menuBar->Append( prefs_menu, _( "P&references" ) );
|
menuBar->Append( prefs_menu, _( "P&references" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,11 @@ static void prepareHelpMenu( wxMenu* aParentMenu );
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::ReCreateMenuBar()
|
void PCB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
{
|
{
|
||||||
wxString text;
|
// 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();
|
wxMenuBar* menuBar = new wxMenuBar();
|
||||||
|
wxString text;
|
||||||
|
|
||||||
// Recreate all menus:
|
// Recreate all menus:
|
||||||
|
|
||||||
|
@ -144,6 +147,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
|
delete oldMenuBar;
|
||||||
|
|
||||||
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
|
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
|
||||||
// Populate the Action Plugin sub-menu
|
// Populate the Action Plugin sub-menu
|
||||||
|
|
|
@ -118,21 +118,13 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateVToolbar()
|
||||||
// Virtual function
|
// Virtual function
|
||||||
void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar( void )
|
void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar( void )
|
||||||
{
|
{
|
||||||
// Create and try to get the current menubar
|
// wxWidgets handles the Mac Application menu behind the scenes, but that means
|
||||||
wxMenuBar* menuBar = GetMenuBar();
|
// we always have to start from scratch with a new wxMenuBar.
|
||||||
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
||||||
if( !menuBar )
|
wxMenuBar* menuBar = new wxMenuBar();
|
||||||
menuBar = new wxMenuBar();
|
wxString text;
|
||||||
|
|
||||||
// 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:
|
// Recreate all menus:
|
||||||
wxString text;
|
|
||||||
|
|
||||||
// Menu File:
|
// Menu File:
|
||||||
wxMenu* fileMenu = new wxMenu;
|
wxMenu* fileMenu = new wxMenu;
|
||||||
|
@ -202,11 +194,6 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar( void )
|
||||||
menuBar->Append( viewMenu, _( "&View" ) );
|
menuBar->Append( viewMenu, _( "&View" ) );
|
||||||
menuBar->Append( helpMenu, _( "&Help" ) );
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
||||||
|
|
||||||
menuBar->Thaw();
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame, if no previous menubar
|
|
||||||
if( GetMenuBar() == NULL )
|
|
||||||
SetMenuBar( menuBar );
|
SetMenuBar( menuBar );
|
||||||
else
|
delete oldMenuBar;
|
||||||
menuBar->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue