From 38ac1b2f2d66f5ad88ca01d9b63f54283861aac5 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 7 Mar 2022 16:41:26 -0800 Subject: [PATCH] Fix the order of evaluation in the arc printing MapAngles will adjust by small amounts the angles t1 and t2. This adjustment will determine the CW/CCW drawing. Therefore, the MapAngles needs to be called explicitly before the Normalize180() call. Left-to-Right evaluation is not a given for MSVC Fixes https://gitlab.com/kicad/code/kicad/issues/11050 (cherry picked from commit c9fb95b8886bc828de0986f3a031c2aa9159adae) --- eeschema/lib_shape.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp index 3ebb37de78..0f4a19c912 100644 --- a/eeschema/lib_shape.cpp +++ b/eeschema/lib_shape.cpp @@ -256,7 +256,12 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, CalcArcAngles( t1, t2 ); - if( aTransform.MapAngles( &t1, &t2 ) == ( NormalizeAngle180( t1 - t2 ) > 0 ) ) + // N.B. The order of evaluation is critical here as MapAngles will modify t1, t2 + // and the Normalize routine depends on these modifications for the correct output + bool transformed = aTransform.MapAngles( &t1, &t2 ); + bool transformed2 = ( ( t1 - t2 ).Normalize180() > 0 ); + + if( transformed == transformed2 ) std::swap( pt1, pt2 ); }