From 80355f04a9ee8ead6a9db0a7050df2fdd59499bf Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 13 Aug 2021 16:52:11 -0400 Subject: [PATCH] Fix SHAPE_LINE_CHAIN::Replace at end of chain --- libs/kimath/src/geometry/shape_line_chain.cpp | 6 ++++++ pcbnew/dialogs/dialog_board_reannotate.cpp | 5 ++--- qa/libs/kimath/geometry/test_shape_line_chain.cpp | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libs/kimath/src/geometry/shape_line_chain.cpp b/libs/kimath/src/geometry/shape_line_chain.cpp index d21697ee8c..1098c83ff3 100644 --- a/libs/kimath/src/geometry/shape_line_chain.cpp +++ b/libs/kimath/src/geometry/shape_line_chain.cpp @@ -1057,6 +1057,12 @@ void SHAPE_LINE_CHAIN::Append( const SHAPE_ARC& aArc ) void SHAPE_LINE_CHAIN::Insert( size_t aVertex, const VECTOR2I& aP ) { + if( aVertex == m_points.size() ) + { + Append( aP ); + return; + } + wxCHECK( aVertex < m_points.size(), /* void */ ); if( aVertex > 0 && IsPtOnArc( aVertex ) ) diff --git a/pcbnew/dialogs/dialog_board_reannotate.cpp b/pcbnew/dialogs/dialog_board_reannotate.cpp index 10fd274559..ccf1987a5b 100644 --- a/pcbnew/dialogs/dialog_board_reannotate.cpp +++ b/pcbnew/dialogs/dialog_board_reannotate.cpp @@ -645,9 +645,8 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector& aBadR bool annotateBack = m_AnnotateBack->GetValue(); // Unless only doing front bool skipLocked = m_ExcludeLocked->GetValue(); - int errorcount = 0; - unsigned int backstartrefdes; - size_t firstnum = 0; + int errorcount = 0; + size_t firstnum = 0; m_frontFootprints.clear(); m_backFootprints.clear(); diff --git a/qa/libs/kimath/geometry/test_shape_line_chain.cpp b/qa/libs/kimath/geometry/test_shape_line_chain.cpp index bab11efb52..66856628f8 100644 --- a/qa/libs/kimath/geometry/test_shape_line_chain.cpp +++ b/qa/libs/kimath/geometry/test_shape_line_chain.cpp @@ -317,6 +317,11 @@ BOOST_AUTO_TEST_CASE( ReplaceChain ) baseChain.Replace( 1, 23, replaceChain ); BOOST_CHECK_EQUAL( baseChain.PointCount(), linePts.size() - ( 23 - 1 ) ); + + // Replacing the last point in a chain is special-cased + baseChain.Replace( baseChain.PointCount() - 1, baseChain.PointCount() - 1, VECTOR2I( -1, -1 ) ); + + BOOST_CHECK_EQUAL( baseChain.CLastPoint(), VECTOR2I( -1, -1 ) ); }