Clamp egregiously large numbers when plotting.

This keeps some plot file viewers (such as Acrobat) from choking.

Fixes https://gitlab.com/kicad/code/kicad/issues/4408
This commit is contained in:
Jeff Young
2020-05-18 13:38:17 +01:00
parent f5bbf24047
commit c7da63151c
+6
View File
@@ -95,6 +95,12 @@ DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate )
{
wxPoint pos = aCoordinate - plotOffset;
// Don't allow overflows; they can cause rendering failures in some file viewers
// (such as Acrobat)
int clampSize = MAX_PAGE_SIZE_MILS * m_IUsPerDecimil * 10 / 2;
pos.x = std::max( -clampSize, std::min( pos.x, clampSize ) );
pos.y = std::max( -clampSize, std::min( pos.y, clampSize ) );
double x = pos.x * plotScale;
double y = ( paperSize.y - pos.y * plotScale );