From 3f73bbcc4f6fda48b632f94bd7168906c204ed08 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 22 Dec 2023 21:20:36 +0000 Subject: [PATCH] Don't run keepUpright when not rotating. For that matter, don't do anything at all for a rotation of 0 (or a move vector of {0,0}). Fixes https://gitlab.com/kicad/code/kicad/-/issues/16402 --- pcbnew/footprint.cpp | 10 ++++++++-- pcbnew/pcb_text.cpp | 2 +- pcbnew/pcb_text.h | 2 +- pcbnew/tools/edit_tool.cpp | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 3de068ca68..8c5a30994b 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -1894,6 +1894,9 @@ const wxChar* FOOTPRINT::StringLibNameInvalidChars( bool aUserReadable ) void FOOTPRINT::Move( const VECTOR2I& aMoveVector ) { + if( aMoveVector.x == 0 && aMoveVector.y == 0 ) + return; + VECTOR2I newpos = m_pos + aMoveVector; SetPosition( newpos ); } @@ -1901,6 +1904,9 @@ void FOOTPRINT::Move( const VECTOR2I& aMoveVector ) void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) { + if( aAngle == ANGLE_0 ) + return; + EDA_ANGLE orientation = GetOrientation(); EDA_ANGLE newOrientation = orientation + aAngle; VECTOR2I newpos = m_pos; @@ -1909,12 +1915,12 @@ void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) SetOrientation( newOrientation ); for( PCB_FIELD* field : m_fields ) - field->KeepUpright( orientation, newOrientation ); + field->KeepUpright( newOrientation ); for( BOARD_ITEM* item : m_drawings ) { if( item->Type() == PCB_TEXT_T ) - static_cast( item )->KeepUpright( orientation, newOrientation ); + static_cast( item )->KeepUpright( newOrientation ); } m_boundingBoxCacheTimeStamp = 0; diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 33e846a15b..10ddcfaacc 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -263,7 +263,7 @@ void PCB_TEXT::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) } -void PCB_TEXT::KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation ) +void PCB_TEXT::KeepUpright( const EDA_ANGLE& aNewOrientation ) { if( !IsKeepUpright() ) return; diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index dcf647ed10..9f10c1893c 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -70,7 +70,7 @@ public: /** * Called when rotating the parent footprint. */ - void KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation ); + void KeepUpright( const EDA_ANGLE& aNewOrientation ); wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 00acdb7b99..0a5f1e59d4 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -2357,7 +2357,8 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent ) case ROTATE_AROUND_ITEM_ANCHOR: boardItem->Rotate( boardItem->GetPosition(), angle ); break; - case ROTATE_AROUND_SEL_CENTER: boardItem->Rotate( selCenter, angle ); + case ROTATE_AROUND_SEL_CENTER: + boardItem->Rotate( selCenter, angle ); break; case ROTATE_AROUND_USER_ORIGIN: boardItem->Rotate( frame()->GetScreen()->m_LocalOrigin, angle );