From f218da6ea58fb8911cebd3deecbc6747740215c6 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 10 Mar 2022 09:43:21 -0800 Subject: [PATCH] Help repair invalid rotation settings We had a period where we were writing invalid rotations leading to values too large by a factor of 100. This clamps the stored values while repairing those affected Fixes https://gitlab.com/kicad/code/kicad/issues/11090 --- pcbnew/pcbnew_settings.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index 46bee3a410..470fb1ac46 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -135,12 +135,22 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_params.emplace_back( new PARAM_LAMBDA( "editing.rotation_angle", [this] () -> int { - return m_RotationAngle.AsTenthsOfADegree(); + int rot = m_RotationAngle.AsTenthsOfADegree(); + + // Don't store values larger than 360 degrees + return rot % 3600; }, [this] ( int aVal ) { if( aVal ) m_RotationAngle = EDA_ANGLE( aVal, TENTHS_OF_A_DEGREE_T ); + + // A misconfiguration allowed some angles to be stored as tenth of a degree but read + // as tens of degrees. By disallowing storage of values larger than 360, we can weed out + // those invalid values here. + while( m_RotationAngle > ANGLE_360 ) + m_RotationAngle = m_RotationAngle / 100; + }, 900 ) );