From c7da63151cc60c795ffbbefe04798f2a6048f864 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 18 May 2020 13:37:23 +0100 Subject: [PATCH] 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 --- common/plotters/plotter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index 5d2be2a0d0..629cded16e 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -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 );