From 403a1a7e1ffba894819467b7efbe4366a67c20af Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 12 Feb 2013 20:01:22 -0500 Subject: [PATCH] Fix bug caused by setting default drill size in D_PAD (fixes lp:1123392). * Add check for pad type and force drill size to zero if pad is surface mount in PCB_PARSER. * Modify the D_PAD SetAttribute method to clear drill size if pad type is set to surface mount. --- pcbnew/class_pad.cpp | 9 +++++++++ pcbnew/class_pad.h | 2 +- pcbnew/pcb_parser.cpp | 13 ++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 1e82f3ddf1..a2762e1b5c 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -135,6 +135,15 @@ EDA_RECT D_PAD::GetBoundingBox() const } +void D_PAD::SetAttribute( PAD_ATTR_T aAttribute ) +{ + m_Attribute = aAttribute; + + if( aAttribute == PAD_SMD ) + m_Drill = wxSize( 0, 0 ); +} + + void D_PAD::SetOrientation( double aAngle ) { NORMALIZE_ANGLE_POS( aAngle ); diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 3055efb836..2a58543ec6 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -189,7 +189,7 @@ public: void SetLayerMask( int aLayerMask ) { m_layerMask = aLayerMask; } int GetLayerMask() const { return m_layerMask; } - void SetAttribute( PAD_ATTR_T aAttribute ) { m_Attribute = aAttribute; } + void SetAttribute( PAD_ATTR_T aAttribute ); PAD_ATTR_T GetAttribute() const { return m_Attribute; } void SetPadToDieLength( int aLength ) { m_LengthPadToDie = aLength; } diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index f081aae45e..389721297f 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -2002,6 +2002,9 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR ) case T_smd: pad->SetAttribute( PAD_SMD ); + + // Default D_PAD object is thru hole with drill. + pad->SetDrillSize( wxSize( 0, 0 ) ); break; case T_connect: @@ -2130,7 +2133,15 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR ) } } - pad->SetDrillSize( drillSize ); + // This fixes a bug caused by setting the default D_PAD drill size to a value + // other than 0 used to fix a bunch of debug assertions even though it is defined + // as a through hole pad. Wouldn't a though hole pad with no drill be a surface + // mount pad? + if( pad->GetAttribute() != PAD_SMD ) + pad->SetDrillSize( drillSize ); + else + pad->SetDrillSize( wxSize( 0, 0 ) ); + break; }