Revert "Stop leaking submenu items"

This reverts commit 34c70a51ea.
This commit is contained in:
Marek Roszko 2022-04-10 22:33:43 -04:00
parent 34c70a51ea
commit 5bb2cdf73d
10 changed files with 31 additions and 32 deletions

View File

@ -138,7 +138,7 @@ void EDA_3D_VIEWER_FRAME::CreateMenuBar()
gridSubmenu->Add( EDA_3D_ACTIONS::show2_5mmGrid, ACTION_MENU::CHECK); gridSubmenu->Add( EDA_3D_ACTIONS::show2_5mmGrid, ACTION_MENU::CHECK);
gridSubmenu->Add( EDA_3D_ACTIONS::show1mmGrid, ACTION_MENU::CHECK); gridSubmenu->Add( EDA_3D_ACTIONS::show1mmGrid, ACTION_MENU::CHECK);
prefsMenu->Add( gridSubmenu, false ); prefsMenu->Add( gridSubmenu );
//-- Menubar ------------------------------------------------------------- //-- Menubar -------------------------------------------------------------
// //

View File

@ -181,9 +181,9 @@ wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry
} }
wxMenuItem* ACTION_MENU::Add( ACTION_MENU* aMenu, bool aClone ) wxMenuItem* ACTION_MENU::Add( ACTION_MENU* aMenu )
{ {
ACTION_MENU* menuCopy = aClone ? aMenu->Clone() : aMenu; ACTION_MENU* menuCopy = aMenu->Clone();
m_submenus.push_back( menuCopy ); m_submenus.push_back( menuCopy );
wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for ACTION_MENU using SetTitle()" ); wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for ACTION_MENU using SetTitle()" );

View File

@ -107,7 +107,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
BITMAPS::import_document ); BITMAPS::import_document );
submenuImport->Add( EE_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) ); submenuImport->Add( EE_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) );
fileMenu->Add( submenuImport, false ); fileMenu->Add( submenuImport );
// Export submenu // Export submenu
@ -116,7 +116,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
submenuExport->SetIcon( BITMAPS::export_file ); submenuExport->SetIcon( BITMAPS::export_file );
submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) ); submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) );
submenuExport->Add( EE_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) ); submenuExport->Add( EE_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) );
fileMenu->Add( submenuExport, false ); fileMenu->Add( submenuExport );
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Add( EE_ACTIONS::schematicSetup ); fileMenu->Add( EE_ACTIONS::schematicSetup );
@ -184,7 +184,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu, false ); viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK ); viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );

View File

@ -70,7 +70,7 @@ void SYMBOL_EDIT_FRAME::ReCreateMenuBar()
submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) ); submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
submenuExport->Add( EE_ACTIONS::exportSymbolView, ACTION_MENU::NORMAL, _( "View as PNG..." ) ); submenuExport->Add( EE_ACTIONS::exportSymbolView, ACTION_MENU::NORMAL, _( "View as PNG..." ) );
submenuExport->Add( EE_ACTIONS::exportSymbolAsSVG, ACTION_MENU::NORMAL, _( "Symbol as SVG..." ) ); submenuExport->Add( EE_ACTIONS::exportSymbolAsSVG, ACTION_MENU::NORMAL, _( "Symbol as SVG..." ) );
fileMenu->Add( submenuExport, false ); fileMenu->Add( submenuExport );
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Add( EE_ACTIONS::symbolProperties ); fileMenu->Add( EE_ACTIONS::symbolProperties );
@ -125,7 +125,7 @@ void SYMBOL_EDIT_FRAME::ReCreateMenuBar()
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu, false ); viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK ); viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );

View File

@ -178,7 +178,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu, false ); viewMenu->Add( unitsSubMenu );
viewMenu->AppendSeparator(); viewMenu->AppendSeparator();
viewMenu->Add( GERBVIEW_ACTIONS::flashedDisplayOutlines, ACTION_MENU::CHECK ); viewMenu->Add( GERBVIEW_ACTIONS::flashedDisplayOutlines, ACTION_MENU::CHECK );

View File

@ -105,9 +105,8 @@ public:
* handle icons. * handle icons.
* *
* @param aMenu is the submenu to be added. * @param aMenu is the submenu to be added.
* @param aClone is whether or not the submenu should be copied from a reference submenu
*/ */
wxMenuItem* Add( ACTION_MENU* aMenu, bool aClone = true ); wxMenuItem* Add( ACTION_MENU* aMenu );
/** /**
* Add a standard close item to the menu with the accelerator key CTRL-W. * Add a standard close item to the menu with the accelerator key CTRL-W.

View File

@ -95,21 +95,21 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
//Import Sub-menu //Import Sub-menu
ACTION_MENU* importSubMenu = new ACTION_MENU( false, controlTool ); ACTION_MENU* importMenu = new ACTION_MENU( false, controlTool );
importSubMenu->SetTitle( _( "Import Non-KiCad Project..." ) ); importMenu->SetTitle( _( "Import Non-KiCad Project..." ) );
importSubMenu->SetIcon( BITMAPS::import_project ); importMenu->SetIcon( BITMAPS::import_project );
importSubMenu->Add( _( "CADSTAR Project..." ), importMenu->Add( _( "CADSTAR Project..." ),
_( "Import CADSTAR Archive Schematic and PCB (*.csa, *.cpa)" ), _( "Import CADSTAR Archive Schematic and PCB (*.csa, *.cpa)" ),
ID_IMPORT_CADSTAR_ARCHIVE_PROJECT, ID_IMPORT_CADSTAR_ARCHIVE_PROJECT,
BITMAPS::import_project ); BITMAPS::import_project );
importSubMenu->Add( _( "EAGLE Project..." ), importMenu->Add( _( "EAGLE Project..." ),
_( "Import EAGLE CAD XML schematic and board" ), _( "Import EAGLE CAD XML schematic and board" ),
ID_IMPORT_EAGLE_PROJECT, ID_IMPORT_EAGLE_PROJECT,
BITMAPS::import_project ); BITMAPS::import_project );
fileMenu->Add( importSubMenu, false ); fileMenu->Add( importMenu );
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Add( _( "&Archive Project..." ), fileMenu->Add( _( "&Archive Project..." ),

View File

@ -118,7 +118,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu, false ); viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK ); viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );

View File

@ -68,7 +68,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
submenuImport->Add( PCB_ACTIONS::importFootprint, ACTION_MENU::NORMAL, _( "Footprint..." ) ); submenuImport->Add( PCB_ACTIONS::importFootprint, ACTION_MENU::NORMAL, _( "Footprint..." ) );
submenuImport->Add( PCB_ACTIONS::placeImportedGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) ); submenuImport->Add( PCB_ACTIONS::placeImportedGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
fileMenu->Add( submenuImport, false ); fileMenu->Add( submenuImport );
ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool ); ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetTitle( _( "Export" ) );
@ -80,7 +80,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
ID_FPEDIT_SAVE_PNG, ID_FPEDIT_SAVE_PNG,
BITMAPS::export_png ); BITMAPS::export_png );
fileMenu->Add( submenuExport, false ); fileMenu->Add( submenuExport );
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Add( PCB_ACTIONS::footprintProperties ); fileMenu->Add( PCB_ACTIONS::footprintProperties );
@ -140,7 +140,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu, false ); viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK ); viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );
@ -153,7 +153,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK ); drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK ); drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK ); drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
viewMenu->Add( drawingModeSubMenu, false ); viewMenu->Add( drawingModeSubMenu );
// Contrast Mode Submenu // Contrast Mode Submenu
ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool ); ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
@ -163,7 +163,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK ); contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec ); contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc ); contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
viewMenu->Add( contrastModeSubMenu, false ); viewMenu->Add( contrastModeSubMenu );
viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK ); viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );

View File

@ -119,7 +119,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
} }
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Add( submenuImport, false ); fileMenu->Add( submenuImport );
// Export submenu // Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool ); ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
@ -157,7 +157,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
"(if the library already exists it will be replaced)" ), "(if the library already exists it will be replaced)" ),
ID_MENU_EXPORT_FOOTPRINTS_TO_NEW_LIBRARY, BITMAPS::library_archive_as ); ID_MENU_EXPORT_FOOTPRINTS_TO_NEW_LIBRARY, BITMAPS::library_archive_as );
fileMenu->Add( submenuExport, false ); fileMenu->Add( submenuExport );
// Fabrication Outputs submenu // Fabrication Outputs submenu
ACTION_MENU* submenuFabOutputs = new ACTION_MENU( false, selTool ); ACTION_MENU* submenuFabOutputs = new ACTION_MENU( false, selTool );
@ -170,7 +170,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
submenuFabOutputs->Add( PCB_ACTIONS::generateReportFile ); submenuFabOutputs->Add( PCB_ACTIONS::generateReportFile );
submenuFabOutputs->Add( PCB_ACTIONS::generateD356File ); submenuFabOutputs->Add( PCB_ACTIONS::generateD356File );
submenuFabOutputs->Add( PCB_ACTIONS::generateBOM ); submenuFabOutputs->Add( PCB_ACTIONS::generateBOM );
fileMenu->Add( submenuFabOutputs, false ); fileMenu->Add( submenuFabOutputs );
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Add( PCB_ACTIONS::boardSetup ); fileMenu->Add( PCB_ACTIONS::boardSetup );
@ -246,7 +246,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK ); unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu, false ); viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK ); viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );
@ -278,7 +278,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK ); drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK ); drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
viewMenu->Add( drawingModeSubMenu, false ); viewMenu->Add( drawingModeSubMenu );
// Contrast Mode Submenu // Contrast Mode Submenu
ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool ); ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
@ -288,7 +288,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK ); contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec ); contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc ); contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
viewMenu->Add( contrastModeSubMenu, false ); viewMenu->Add( contrastModeSubMenu );
viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK ); viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );
@ -313,7 +313,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
muwaveSubmenu->Add( PCB_ACTIONS::microwaveCreateStub ); muwaveSubmenu->Add( PCB_ACTIONS::microwaveCreateStub );
muwaveSubmenu->Add( PCB_ACTIONS::microwaveCreateStubArc ); muwaveSubmenu->Add( PCB_ACTIONS::microwaveCreateStubArc );
muwaveSubmenu->Add( PCB_ACTIONS::microwaveCreateFunctionShape ); muwaveSubmenu->Add( PCB_ACTIONS::microwaveCreateFunctionShape );
placeMenu->Add( muwaveSubmenu, false ); placeMenu->Add( muwaveSubmenu );
placeMenu->AppendSeparator(); placeMenu->AppendSeparator();
placeMenu->Add( PCB_ACTIONS::drawLine ); placeMenu->Add( PCB_ACTIONS::drawLine );
@ -349,7 +349,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents ); autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents );
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceSelectedComponents ); autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceSelectedComponents );
placeMenu->Add( autoplaceSubmenu, false ); placeMenu->Add( autoplaceSubmenu );
//-- Route Menu ---------------------------------------------------------- //-- Route Menu ----------------------------------------------------------
@ -444,7 +444,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
buildActionPluginMenus( submenuActionPlugins ); buildActionPluginMenus( submenuActionPlugins );
toolsMenu->AppendSeparator(); toolsMenu->AppendSeparator();
toolsMenu->Add( submenuActionPlugins, false ); toolsMenu->Add( submenuActionPlugins );
//-- Preferences menu ---------------------------------------------------- //-- Preferences menu ----------------------------------------------------
// //