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
This commit is contained in:
Mike Williams 2022-02-18 12:40:39 -05:00 committed by Wayne Stambaugh
parent d1a4daefbb
commit d0749c4e9a
2 changed files with 20 additions and 5 deletions

View File

@ -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();
}

View File

@ -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<SCH_LINE*, EDA_ITEMS> m_lineConnectionCache;
///< Lines added at bend points dynamically during the move
std::unordered_set<SCH_LINE*> m_newDragLines;
///< Lines changed by drag algorithm that weren't selected
std::unordered_set<SCH_LINE*> m_changedDragLines;
///< Used for chaining commands
VECTOR2I m_moveOffset;