From fd0b364b914b2c3da1f71d5eca8ccc8bdec76182 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 12 Feb 2018 08:23:30 -0800 Subject: [PATCH] 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 --- eeschema/block.cpp | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 3b6e2d8757..00c7e3830b 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -187,6 +187,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) { bool nextcmd = false; bool zoom_command = false; + bool append = false; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; if( block->GetCount() ) @@ -273,17 +274,31 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) } break; + case BLOCK_CUT: case BLOCK_DELETE: GetScreen()->UpdatePickList(); 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 ); OnModify(); + block->ClearItemsList(); + GetScreen()->UpdatePickList(); + append = true; } - block->ClearItemsList(); + GetScreen()->TestDanglingEnds(); m_canvas->Refresh(); break; @@ -302,25 +317,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) block->ClearItemsList(); 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: block->SetState( STATE_BLOCK_MOVE ); break;