PCB_GRID_HELPER::BestSnapAnchor() fix overflow due to use of int.
GRID_HELPER::GetVisibleGrid() needs double, does not work with int (overflow). Fixes #15389 https://gitlab.com/kicad/code/kicad/-/issues/15389
This commit is contained in:
parent
91b3b296fe
commit
7fe80abdff
|
@ -56,11 +56,9 @@ VECTOR2I GRID_HELPER::GetGrid() const
|
|||
}
|
||||
|
||||
|
||||
VECTOR2I GRID_HELPER::GetVisibleGrid() const
|
||||
VECTOR2D GRID_HELPER::GetVisibleGrid() const
|
||||
{
|
||||
VECTOR2D size = m_toolMgr->GetView()->GetGAL()->GetVisibleGridSize();
|
||||
|
||||
return VECTOR2I( KiROUND( size.x ), KiROUND( size.y ) );
|
||||
return m_toolMgr->GetView()->GetGAL()->GetVisibleGridSize();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
virtual ~GRID_HELPER();
|
||||
|
||||
VECTOR2I GetGrid() const;
|
||||
VECTOR2I GetVisibleGrid() const;
|
||||
VECTOR2D GetVisibleGrid() const;
|
||||
VECTOR2I GetOrigin() const;
|
||||
|
||||
void SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin = VECTOR2I( 0, 0 ) );
|
||||
|
|
|
@ -286,8 +286,10 @@ VECTOR2I PCB_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& a
|
|||
// see https://gitlab.com/kicad/code/kicad/-/issues/5638
|
||||
// see https://gitlab.com/kicad/code/kicad/-/issues/7125
|
||||
// see https://gitlab.com/kicad/code/kicad/-/issues/12303
|
||||
int snapScale = KiROUND( snapSize / m_toolMgr->GetView()->GetGAL()->GetWorldScale() );
|
||||
int snapRange = m_enableGrid ? std::min( snapScale, GetVisibleGrid().x ) : snapScale;
|
||||
double snapScale = snapSize / m_toolMgr->GetView()->GetGAL()->GetWorldScale();
|
||||
// warning: GetVisibleGrid().x sometimes returns a value > INT_MAX. Intermediate calculation
|
||||
// needs double.
|
||||
int snapRange = KiROUND( m_enableGrid ? std::min( snapScale, GetVisibleGrid().x ) : snapScale );
|
||||
int snapDist = snapRange;
|
||||
|
||||
//Respect limits of coordinates representation
|
||||
|
|
Loading…
Reference in New Issue