From 87e163945ea3181394f803ce8ce7f6ae9f31fcc6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 24 Dec 2019 22:12:16 +0000 Subject: [PATCH] Items added to a selection for a drag should only be temporary. After the drag, cancel, or undo, only the originally-selected items should remain selected. --- eeschema/tools/ee_tool_base.h | 9 +++++++++ eeschema/tools/sch_move_tool.cpp | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/eeschema/tools/ee_tool_base.h b/eeschema/tools/ee_tool_base.h index 77c55d935e..0b230c85a5 100644 --- a/eeschema/tools/ee_tool_base.h +++ b/eeschema/tools/ee_tool_base.h @@ -117,6 +117,12 @@ protected: void saveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO_T aType, bool aAppend = false ) { KICAD_T itemType = aItem->Type(); + bool selected = aItem->IsSelected(); + + // IS_SELECTED flag should not be set on undo items which were added for + // a drag operation. + if( selected && aItem->HasFlag( TEMP_SELECTED )) + aItem->ClearSelected(); if( m_isLibEdit ) { @@ -133,6 +139,9 @@ protected: else editFrame->SaveCopyInUndoList( (SCH_ITEM*) aItem, aType, aAppend ); } + + if( selected && aItem->HasFlag( TEMP_SELECTED ) ) + aItem->SetSelected(); } protected: diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 9250512f3f..7bb3836c23 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -234,7 +234,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) { if( item->IsNew() ) { - if( item->HasFlag(TEMP_SELECTED ) && m_isDragOperation ) + if( item->HasFlag( TEMP_SELECTED ) && m_isDragOperation ) { // Item was added in getConnectedDragItems saveCopyInUndoList( (SCH_ITEM*) item, UR_NEW, appendUndo ); @@ -431,6 +431,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selection ) item->ClearEditFlags(); + m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE ); + if( restore_state ) { m_frame->RollbackSchematicFromUndo();