Correctly order swap test

MapAngles() will modify parameters and C++ does not guarantee LTR
evaluation, so we need to separate the calls into the proper order
before comparing the returns

Fixes https://gitlab.com/kicad/code/kicad/issues/11135
This commit is contained in:
Seth Hillbrand 2022-03-24 09:22:11 -07:00
parent 92a229eec7
commit c686105afc
1 changed files with 6 additions and 1 deletions

View File

@ -142,7 +142,12 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs
CalcArcAngles( t1, t2 );
if( aTransform.MapAngles( &t1, &t2 ) != ( ( t1 - t2 ).Normalize180() > ANGLE_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() > ANGLE_0 );
if( transformed != transformed2 )
std::swap( start, end );
}