Fixes: lp:1690840 (Pcbnew crashes when creating a drill file)
https://bugs.launchpad.net/kicad/+bug/1690840
This commit is contained in:
parent
499eabceb4
commit
f77db7b4b9
|
@ -50,14 +50,18 @@ static bool CmpHoleSorting( const HOLE_INFO& a, const HOLE_INFO& b )
|
||||||
|
|
||||||
if( pada && padb )
|
if( pada && padb )
|
||||||
{
|
{
|
||||||
if( pada->GetParent()->GetReference().Cmp( padb->GetParent()->GetReference() ) != 0 )
|
// cmp == 0 means the pads have the same parent, therfore the same reference
|
||||||
return pada->GetParent()->GetReference().Cmp( padb->GetParent()->GetReference() ) < 0;
|
int cmp = pada->GetParent() - padb->GetParent();
|
||||||
|
|
||||||
|
if( cmp )
|
||||||
|
return cmp < 0;
|
||||||
|
}
|
||||||
|
else if( pada || padb ) // in this case, other item is a via. Sort via first
|
||||||
|
{
|
||||||
|
return padb != nullptr;
|
||||||
}
|
}
|
||||||
else if( pada || padb )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// At this point, holes are via holes: sort by position
|
|
||||||
|
|
||||||
|
// At this point, sort by position, as last sort criteria
|
||||||
if( a.m_Hole_Pos.x != b.m_Hole_Pos.x )
|
if( a.m_Hole_Pos.x != b.m_Hole_Pos.x )
|
||||||
return a.m_Hole_Pos.x < b.m_Hole_Pos.x;
|
return a.m_Hole_Pos.x < b.m_Hole_Pos.x;
|
||||||
|
|
||||||
|
|
|
@ -220,6 +220,7 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
|
||||||
holes_count = 0;
|
holes_count = 0;
|
||||||
|
|
||||||
wxPoint hole_pos;
|
wxPoint hole_pos;
|
||||||
|
bool last_item_is_via = true; // a flag to clear object attributes when a via hole is created.
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
|
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
|
||||||
{
|
{
|
||||||
|
@ -233,9 +234,21 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
|
||||||
GBR_METADATA gbr_metadata;
|
GBR_METADATA gbr_metadata;
|
||||||
|
|
||||||
if( dyn_cast<const VIA*>(hole_descr.m_ItemParent ) )
|
if( dyn_cast<const VIA*>(hole_descr.m_ItemParent ) )
|
||||||
|
{
|
||||||
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIADRILL );
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIADRILL );
|
||||||
|
|
||||||
|
if( !last_item_is_via )
|
||||||
|
{
|
||||||
|
// be sure the current object attribute is cleared for vias
|
||||||
|
plotter.EndBlock( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
last_item_is_via = true;
|
||||||
|
}
|
||||||
else if( dyn_cast<const D_PAD*>( hole_descr.m_ItemParent ) )
|
else if( dyn_cast<const D_PAD*>( hole_descr.m_ItemParent ) )
|
||||||
{
|
{
|
||||||
|
last_item_is_via = false;
|
||||||
|
|
||||||
if( hole_descr.m_Hole_Shape )
|
if( hole_descr.m_Hole_Shape )
|
||||||
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SLOTDRILL );
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SLOTDRILL );
|
||||||
else
|
else
|
||||||
|
@ -243,7 +256,13 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
|
||||||
|
|
||||||
// Add object attribute: component reference to pads (mainly usefull for users)
|
// Add object attribute: component reference to pads (mainly usefull for users)
|
||||||
const D_PAD* pad = dyn_cast<const D_PAD*>( hole_descr.m_ItemParent );
|
const D_PAD* pad = dyn_cast<const D_PAD*>( hole_descr.m_ItemParent );
|
||||||
gbr_metadata.SetCmpReference( pad->GetParent()->GetReference() );
|
wxString ref = pad->GetParent()->GetReference();
|
||||||
|
|
||||||
|
#if 0 // Set to 1 to force a dummy reference for the parent pad.
|
||||||
|
if( ref.IsEmpty() )
|
||||||
|
ref = "<undefinedref>";
|
||||||
|
#endif
|
||||||
|
gbr_metadata.SetCmpReference( ref );
|
||||||
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue