From d23b5f89b3ff7a3deab4f14d02c9ca1d6868cf10 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 12 Jan 2021 23:55:46 +0000 Subject: [PATCH] Don't save sheet multiple times on undo stack. Fixes https://gitlab.com/kicad/code/kicad/issues/7063 --- eeschema/tools/sch_edit_tool.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index b5250d4ca0..cff2585e18 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -64,6 +64,7 @@ #include #include #include +#include class SYMBOL_UNIT_MENU : public ACTION_MENU { @@ -1021,6 +1022,22 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) sch_item->SetFlags( STRUCT_DELETED ); // clean up junctions at the end } + else if( sch_item->Type() == SCH_SHEET_PIN_T ) + { + SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item; + SCH_SHEET* sheet = pin->GetParent(); + + if( !alg::contains( items, sheet ) ) + { + pin->SetFlags( STRUCT_DELETED ); + saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo ); + appendToUndo = true; + + updateItem( pin, false ); + + sheet->RemovePin( pin ); + } + } else { sch_item->SetFlags( STRUCT_DELETED ); @@ -1029,17 +1046,7 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) updateItem( sch_item, false ); - if( sch_item->Type() == SCH_SHEET_PIN_T ) - { - SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item; - SCH_SHEET* sheet = pin->GetParent(); - - sheet->RemovePin( pin ); - } - else - { - m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() ); - } + m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() ); if( sch_item->Type() == SCH_SHEET_T ) m_frame->UpdateHierarchyNavigator();