diff --git a/libs/kimath/include/geometry/seg.h b/libs/kimath/include/geometry/seg.h index e1d2550f4d..158c29d3c4 100644 --- a/libs/kimath/include/geometry/seg.h +++ b/libs/kimath/include/geometry/seg.h @@ -3,6 +3,7 @@ * * Copyright (C) 2013 CERN * @author Tomasz Wlostowski + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/kimath/include/geometry/shape_circle.h b/libs/kimath/include/geometry/shape_circle.h index bce96b8c18..a1c67b1d9c 100644 --- a/libs/kimath/include/geometry/shape_circle.h +++ b/libs/kimath/include/geometry/shape_circle.h @@ -3,6 +3,7 @@ * * Copyright (C) 2013 CERN * @author Tomasz Wlostowski + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/kimath/include/trigo.h b/libs/kimath/include/trigo.h index 75c3f74e72..79ed7a7ce2 100644 --- a/libs/kimath/include/trigo.h +++ b/libs/kimath/include/trigo.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/kimath/src/geometry/seg.cpp b/libs/kimath/src/geometry/seg.cpp index 975eadf8e6..9858977c65 100644 --- a/libs/kimath/src/geometry/seg.cpp +++ b/libs/kimath/src/geometry/seg.cpp @@ -3,6 +3,7 @@ * * Copyright (C) 2013 CERN * @author Tomasz Wlostowski + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/libs/kimath/src/trigo.cpp b/libs/kimath/src/trigo.cpp index 2c59c7469f..31daca245f 100644 --- a/libs/kimath/src/trigo.cpp +++ b/libs/kimath/src/trigo.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2014-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index ae5896b07d..e5e13bf68c 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2013-2017 CERN * @author Maciej Suminski * @author Tomasz Wlostowski - * Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -295,7 +295,6 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) Activate(); ARC* theArc = static_cast( selection.Front() ); - m_commit->Modify( theArc ); KIGFX::VIEW_CONTROLS* controls = getViewControls(); @@ -329,7 +328,6 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) if( itemsOnAnchor.size() == 1 && itemsOnAnchor.front()->Type() == PCB_TRACE_T ) { retval = static_cast( itemsOnAnchor.front() ); - m_commit->Modify( retval ); } else { @@ -349,6 +347,11 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) TRACK* trackOnStart = getUniqueConnectedTrack( theArc->GetStart() ); TRACK* trackOnEnd = getUniqueConnectedTrack( theArc->GetEnd() ); + // Make copies of items to be edited + ARC* theArcCopy = new ARC( *theArc ); + TRACK* trackOnStartCopy = new TRACK( *trackOnStart ); + TRACK* trackOnEndCopy = new TRACK( *trackOnEnd ); + if( !trackOnStart->IsNew() ) { tanStart.A = trackOnStart->GetStart(); @@ -518,46 +521,50 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) } } - // Remove zero length tracks - if( theArc->GetStart() == theArc->GetEnd() ) - m_commit->Remove( theArc ); - - auto cleanupTrack = - [&]( TRACK* aTrack ) + // Ensure we only do one commit operation on each object + auto processTrack = + [&]( TRACK* aTrack, TRACK* aTrackCopy ) + { + if( aTrack->IsNew() ) { - if( aTrack->IsNew() ) - { - getView()->Remove( aTrack ); + getView()->Remove( aTrack ); - if( aTrack->GetStart() == aTrack->GetEnd() ) - delete aTrack; - else - m_commit->Add( aTrack ); - } - else if( aTrack->GetStart() == aTrack->GetEnd() ) + if( aTrack->GetStart() == aTrack->GetEnd() ) { - m_commit->Remove( aTrack ); + delete aTrack; + delete aTrackCopy; + aTrack = nullptr; + aTrackCopy = nullptr; } - }; + else + { + m_commit->Add( aTrack ); + delete aTrackCopy; + aTrackCopy = nullptr; + } + } + else if( aTrack->GetStart() == aTrack->GetEnd() ) + { + aTrack->SwapData( aTrackCopy ); //restore the original before notifying COMMIT + m_commit->Remove( aTrack ); + delete aTrackCopy; + aTrackCopy = nullptr; + } + else + { + m_commit->Modified( aTrack, aTrackCopy ); + } + }; - cleanupTrack( trackOnStart ); - cleanupTrack( trackOnEnd ); + processTrack( trackOnStart, trackOnStartCopy ); + processTrack( trackOnEnd, trackOnEndCopy ); + processTrack( theArc, theArcCopy ); // Should we commit? if( restore_state ) - { m_commit->Revert(); - - if( trackOnStart->IsNew() ) - delete trackOnStart; - - if( trackOnEnd->IsNew() ) - delete trackOnEnd; - } else - { m_commit->Push( _( "Drag Arc Track" ) ); - } return 0; } diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index 9b0de447e7..d081c944b9 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2020 CERN - * Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * @author Tomasz Wlostowski * diff --git a/qa/libs/kimath/geometry/test_segment.cpp b/qa/libs/kimath/geometry/test_segment.cpp index db13bec6da..2db5672e78 100644 --- a/qa/libs/kimath/geometry/test_segment.cpp +++ b/qa/libs/kimath/geometry/test_segment.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 CERN * @author Alejandro GarcĂ­a Montoro - * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License