Handle delete of sheet pins.

SCH_COMMIT::Stage() can handle promoting the parent, but then the pin
needs to be removed first.  I think it's probably clearer if we just
do the promotion in the delete routine.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15129
This commit is contained in:
Jeff Young 2023-07-09 13:40:06 +01:00
parent a66360525a
commit 6182ff4834
1 changed files with 7 additions and 12 deletions

View File

@ -637,7 +637,6 @@ bool SCH_EDIT_TOOL::Init()
selToolMenu.AddSeparator( 400 ); selToolMenu.AddSeparator( 400 );
selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 ); selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 );
return true; return true;
} }
@ -1172,7 +1171,6 @@ int SCH_EDIT_TOOL::Swap( const TOOL_EVENT& aEvent )
} }
} }
if( selection.Size() < 2 ) if( selection.Size() < 2 )
return 0; return 0;
@ -1382,6 +1380,7 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
std::deque<EDA_ITEM*> items = m_selectionTool->RequestSelection( deletableItems ).GetItems(); std::deque<EDA_ITEM*> items = m_selectionTool->RequestSelection( deletableItems ).GetItems();
SCH_COMMIT commit( m_toolMgr ); SCH_COMMIT commit( m_toolMgr );
std::vector<VECTOR2I> pts; std::vector<VECTOR2I> pts;
bool updateHierarchy = false;
if( items.empty() ) if( items.empty() )
return 0; return 0;
@ -1417,27 +1416,20 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
if( !alg::contains( items, sheet ) ) if( !alg::contains( items, sheet ) )
{ {
pin->SetFlags( STRUCT_DELETED ); commit.Modify( sheet, m_frame->GetScreen() );
updateItem( pin, false );
sheet->RemovePin( pin ); sheet->RemovePin( pin );
commit.Removed( pin, m_frame->GetScreen() );
} }
} }
else if( sch_item->Type() == SCH_FIELD_T ) else if( sch_item->Type() == SCH_FIELD_T )
{ {
commit.Modify( item, m_frame->GetScreen() ); commit.Modify( item, m_frame->GetScreen() );
static_cast<SCH_FIELD*>( sch_item )->SetVisible( false ); static_cast<SCH_FIELD*>( sch_item )->SetVisible( false );
updateItem( sch_item, false );
} }
else else
{ {
sch_item->SetFlags( STRUCT_DELETED ); sch_item->SetFlags( STRUCT_DELETED );
updateItem( sch_item, false ); commit.Remove( item, m_frame->GetScreen() );
m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() ); updateHierarchy |= ( sch_item->Type() == SCH_SHEET_T );
commit.Removed( item, m_frame->GetScreen() );
if( sch_item->Type() == SCH_SHEET_T )
m_frame->UpdateHierarchyNavigator();
} }
} }
@ -1454,6 +1446,9 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
commit.Push( _( "Delete" ) ); commit.Push( _( "Delete" ) );
if( updateHierarchy )
m_frame->UpdateHierarchyNavigator();
return 0; return 0;
} }