From 092c61e021e5a2e629d7f0330eb520af6b518b2c Mon Sep 17 00:00:00 2001
From: Maciej Suminski <maciej.suminski@cern.ch>
Date: Sat, 11 Feb 2017 09:18:02 +0100
Subject: [PATCH] More robust condition to avoid division by 0 in
 D_PAD::ViewGetLOD()

---
 pcbnew/class_pad.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp
index b4c7c246f8..962ee44ce5 100644
--- a/pcbnew/class_pad.cpp
+++ b/pcbnew/class_pad.cpp
@@ -972,12 +972,14 @@ unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
     // Netnames will be shown only if zoom is appropriate
     if( IsNetnameLayer( aLayer ) )
     {
-        // Pad sizes can be zero briefly when someone is typing a number like "0.5" in the pad properties dialog.
-        // Fail gracefully if this happens.
-        if( ( m_Size.x == 0 ) && ( m_Size.y == 0 ) )
+        int divisor = std::max( m_Size.x, m_Size.y );
+
+        // Pad sizes can be zero briefly when someone is typing a number like "0.5"
+        // in the pad properties dialog
+        if( divisor == 0 )
             return UINT_MAX;
 
-        return ( Millimeter2iu( 100 ) / std::max( m_Size.x, m_Size.y ) );
+        return ( Millimeter2iu( 100 ) / divisor );
     }
 
     // Other layers are shown without any conditions