Eeschema: Ensure all items in a block are deleted

Deleting lines can create new ones when old lines are merged as the
result of a delete operation.  This checks that all items inside a
selection block are deleted before finishing.

Fixes: lp:1748907
* https://bugs.launchpad.net/kicad/+bug/1748907
This commit is contained in:
Seth Hillbrand 2018-02-12 08:23:30 -08:00 committed by Wayne Stambaugh
parent f69d499527
commit fd0b364b91
1 changed files with 18 additions and 22 deletions

View File

@ -187,6 +187,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
{ {
bool nextcmd = false; bool nextcmd = false;
bool zoom_command = false; bool zoom_command = false;
bool append = false;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
if( block->GetCount() ) if( block->GetCount() )
@ -273,17 +274,31 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
} }
break; break;
case BLOCK_CUT:
case BLOCK_DELETE: case BLOCK_DELETE:
GetScreen()->UpdatePickList(); GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false ); DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() ) // The CUT variant needs to copy the items from their originial position
if( ( block->GetCommand() == BLOCK_CUT ) && block->GetCount() )
{ {
DeleteItemsInList( block->GetItems() ); wxPoint move_vector = -GetScreen()->m_BlockLocate.GetLastCursorPosition();
copyBlockItems( block->GetItems() );
MoveItemsInList( m_blockItems.GetItems(), move_vector );
}
// We set this in a while loop to catch any newly created items
// as a result of the delete (e.g. merged wires)
while( block->GetCount() )
{
DeleteItemsInList( block->GetItems(), append );
SchematicCleanUp( true ); SchematicCleanUp( true );
OnModify(); OnModify();
block->ClearItemsList();
GetScreen()->UpdatePickList();
append = true;
} }
block->ClearItemsList();
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
@ -302,25 +317,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
block->ClearItemsList(); block->ClearItemsList();
break; break;
case BLOCK_CUT:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
wxPoint move_vector = -GetScreen()->m_BlockLocate.GetLastCursorPosition();
copyBlockItems( block->GetItems() );
MoveItemsInList( m_blockItems.GetItems(), move_vector );
DeleteItemsInList( block->GetItems() );
SchematicCleanUp( true );
OnModify();
}
block->ClearItemsList();
GetScreen()->TestDanglingEnds();
m_canvas->Refresh();
break;
case BLOCK_PASTE: case BLOCK_PASTE:
block->SetState( STATE_BLOCK_MOVE ); block->SetState( STATE_BLOCK_MOVE );
break; break;