From d0749c4e9a28107326aba75248175851ce8e1b8a Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Fri, 18 Feb 2022 12:40:39 -0500 Subject: [PATCH] Schematic: more drag undo fixes Drag was not clearing IS_CHANGED status of items that were moved by the drag, but weren't selected or created by it. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10845 --- eeschema/tools/sch_move_tool.cpp | 21 +++++++++++++++++---- eeschema/tools/sch_move_tool.h | 4 +++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index d328f4576c..6b3da856f5 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -524,9 +524,14 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // adding them. if( !foundLine->HasFlag( IS_CHANGED ) && !foundLine->HasFlag( IS_NEW ) ) + { saveCopyInUndoList( (SCH_ITEM*) foundLine, UNDO_REDO::CHANGED, true ); + if( !foundLine->IsSelected() ) + m_changedDragLines.insert( foundLine ); + } + if( foundLine->GetStartPoint() == unselectedEnd ) foundLine->MoveStart( splitDelta ); else if( foundLine->GetEndPoint() == unselectedEnd ) @@ -807,8 +812,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) } while( ( evt = Wait() ) ); //Should be assignment not equality test - // Save whatever new bend lines survived the drag - commitNewDragLines(); + // Save whatever new bend lines and changed lines survived the drag + commitDragLines(); controls->ForceCursorPosition( false ); controls->ShowCursor( false ); @@ -1454,15 +1459,23 @@ void SCH_MOVE_TOOL::setTransitions() } -void SCH_MOVE_TOOL::commitNewDragLines() +void SCH_MOVE_TOOL::commitDragLines() { for( auto newLine : m_newDragLines ) { - saveCopyInUndoList( newLine, UNDO_REDO::NEWITEM, true ); newLine->ClearEditFlags(); + saveCopyInUndoList( newLine, UNDO_REDO::NEWITEM, true ); + } + + // These lines have been changed, but aren't selected. We need + // to manually clear these edit flags or they'll stick around. + for( auto oldLine : m_changedDragLines ) + { + oldLine->ClearEditFlags(); } m_newDragLines.clear(); + m_changedDragLines.clear(); } diff --git a/eeschema/tools/sch_move_tool.h b/eeschema/tools/sch_move_tool.h index d215745a04..7f5ac1d42c 100644 --- a/eeschema/tools/sch_move_tool.h +++ b/eeschema/tools/sch_move_tool.h @@ -75,7 +75,7 @@ private: void setTransitions() override; ///< Saves the new drag lines to the undo list - void commitNewDragLines(); + void commitDragLines(); ///< Clears the new drag lines and removes them from the screen void clearNewDragLines(); @@ -91,6 +91,8 @@ private: std::map m_lineConnectionCache; ///< Lines added at bend points dynamically during the move std::unordered_set m_newDragLines; + ///< Lines changed by drag algorithm that weren't selected + std::unordered_set m_changedDragLines; ///< Used for chaining commands VECTOR2I m_moveOffset;