Change the behavior of ACTION_MENU::Add to require clones if required outside the function
This reverts commit 2a5769607f
.
This commit is contained in:
parent
16acba34d3
commit
f88e0481c8
|
@ -183,21 +183,20 @@ wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry
|
|||
|
||||
wxMenuItem* ACTION_MENU::Add( ACTION_MENU* aMenu )
|
||||
{
|
||||
ACTION_MENU* menuCopy = aMenu->Clone();
|
||||
m_submenus.push_back( menuCopy );
|
||||
m_submenus.push_back( aMenu );
|
||||
|
||||
wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for ACTION_MENU using SetTitle()" );
|
||||
wxASSERT_MSG( !aMenu->m_title.IsEmpty(), "Set a title for ACTION_MENU using SetTitle()" );
|
||||
|
||||
if( !!aMenu->m_icon )
|
||||
{
|
||||
wxMenuItem* newItem = new wxMenuItem( this, -1, menuCopy->m_title );
|
||||
wxMenuItem* newItem = new wxMenuItem( this, -1, aMenu->m_title );
|
||||
AddBitmapToMenuItem( newItem, KiBitmap( aMenu->m_icon ) );
|
||||
newItem->SetSubMenu( menuCopy );
|
||||
newItem->SetSubMenu( aMenu );
|
||||
return Append( newItem );
|
||||
}
|
||||
else
|
||||
{
|
||||
return AppendSubMenu( menuCopy, menuCopy->m_title );
|
||||
return AppendSubMenu( aMenu, aMenu->m_title );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection )
|
|||
|
||||
case ENTRY::MENU:
|
||||
entry.Menu()->UpdateTitle();
|
||||
Add( entry.Menu() );
|
||||
Add( entry.Menu()->Clone() );
|
||||
menu_count++;
|
||||
break;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
|||
fileMenu->Add( ACTIONS::doNew );
|
||||
fileMenu->Add( ACTIONS::open );
|
||||
|
||||
wxMenuItem* item = fileMenu->Add( openRecentMenu );
|
||||
wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
|
||||
|
||||
// Add the file menu condition here since it needs the item ID for the submenu
|
||||
ACTION_CONDITIONS cond;
|
||||
|
|
|
@ -77,7 +77,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
|
|||
|
||||
fileMenu->Add( GERBVIEW_ACTIONS::openAutodetected );
|
||||
fileMenu->Add( GERBVIEW_ACTIONS::openGerber );
|
||||
wxMenuItem* gbrItem = fileMenu->Add( openRecentGbrMenu );
|
||||
wxMenuItem* gbrItem = fileMenu->Add( openRecentGbrMenu->Clone() );
|
||||
RegisterUIUpdateHandler( gbrItem->GetId(), FileHistoryCond( recentGbrFiles) );
|
||||
|
||||
|
||||
|
@ -99,7 +99,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
|
|||
m_drillFileHistory.UpdateClearText( openRecentDrlMenu, _( "Clear Recent Drill Files" ) );
|
||||
|
||||
fileMenu->Add( GERBVIEW_ACTIONS::openDrillFile );
|
||||
wxMenuItem* drillItem = fileMenu->Add( openRecentDrlMenu );
|
||||
wxMenuItem* drillItem = fileMenu->Add( openRecentDrlMenu->Clone() );
|
||||
RegisterUIUpdateHandler( drillItem->GetId(), FileHistoryCond( m_drillFileHistory ) );
|
||||
|
||||
|
||||
|
@ -120,7 +120,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
|
|||
m_jobFileHistory.UpdateClearText( openRecentJobMenu, _( "Clear Recent Job Files" ) );
|
||||
|
||||
fileMenu->Add( GERBVIEW_ACTIONS::openJobFile );
|
||||
wxMenuItem* jobItem = fileMenu->Add( openRecentJobMenu );
|
||||
wxMenuItem* jobItem = fileMenu->Add( openRecentJobMenu->Clone() );
|
||||
RegisterUIUpdateHandler( jobItem->GetId(), FileHistoryCond( m_jobFileHistory ) );
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
|
|||
m_zipFileHistory.UpdateClearText( openRecentZipMenu, _( "Clear Recent Zip Files" ) );
|
||||
|
||||
fileMenu->Add( GERBVIEW_ACTIONS::openZipFile );
|
||||
wxMenuItem* zipItem = fileMenu->Add( openRecentZipMenu );
|
||||
wxMenuItem* zipItem = fileMenu->Add( openRecentZipMenu->Clone() );
|
||||
RegisterUIUpdateHandler( zipItem->GetId(), FileHistoryCond( m_zipFileHistory ) );
|
||||
|
||||
#undef FileHistoryCond
|
||||
|
|
|
@ -104,7 +104,8 @@ public:
|
|||
* The difference between this function and wxMenu::AppendSubMenu() is the capability to
|
||||
* handle icons.
|
||||
*
|
||||
* @param aMenu is the submenu to be added.
|
||||
* @param aMenu is the submenu to be added. This should be a new instance (use Clone()) if required
|
||||
* as the menu is destructed after use.
|
||||
*/
|
||||
wxMenuItem* Add( ACTION_MENU* aMenu );
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
|||
|
||||
fileMenu->Add( KICAD_MANAGER_ACTIONS::openProject );
|
||||
|
||||
wxMenuItem* item = fileMenu->Add( openRecentMenu );
|
||||
wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
|
||||
|
||||
// Add the file menu condition here since it needs the item ID for the submenu
|
||||
ACTION_CONDITIONS cond;
|
||||
|
|
|
@ -71,7 +71,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
|
|||
fileMenu->Add( ACTIONS::doNew );
|
||||
fileMenu->Add( ACTIONS::open );
|
||||
|
||||
wxMenuItem* item = fileMenu->Add( openRecentMenu );
|
||||
wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
|
||||
|
||||
// Add the file menu condition here since it needs the item ID for the submenu
|
||||
ACTION_CONDITIONS cond;
|
||||
|
|
|
@ -77,7 +77,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
|||
fileMenu->Add( ACTIONS::doNew );
|
||||
fileMenu->Add( ACTIONS::open );
|
||||
|
||||
wxMenuItem* item = fileMenu->Add( openRecentMenu );
|
||||
wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
|
||||
|
||||
// Add the file menu condition here since it needs the item ID for the submenu
|
||||
ACTION_CONDITIONS cond;
|
||||
|
|
Loading…
Reference in New Issue