From e9bfcc28c3b76bd2e6d8bf35e8cb0efad4d632d7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 11 Feb 2016 19:12:06 -0500 Subject: [PATCH] Fix HPGL plot divide by zero bug. --- common/common_plotHPGL_functions.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp index 697b1a8541..d412b97a20 100644 --- a/common/common_plotHPGL_functions.cpp +++ b/common/common_plotHPGL_functions.cpp @@ -223,8 +223,6 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, paperSize.y *= 10.0 * aIusPerDecimil; SetDefaultLineWidth( 0 ); // HPGL has pen sizes instead m_plotMirror = aMirror; - penOverlap = 0; - penDiameter = 0; } @@ -685,7 +683,12 @@ void HPGL_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCorne } // Calculation of dd = number of segments was traced to fill. - jj = jj / (int) ( penDiameter - penOverlap ); + int delta = (int) ( penDiameter - penOverlap ); + + if( delta ) + jj = jj / delta; + else + jj = 0; // Trace the outline. for( ; jj > 0; jj-- )