diff --git a/pcbnew/router/pns_hole.cpp b/pcbnew/router/pns_hole.cpp index 689c99978f..bc99a6b375 100644 --- a/pcbnew/router/pns_hole.cpp +++ b/pcbnew/router/pns_hole.cpp @@ -40,7 +40,7 @@ HOLE::~HOLE() HOLE* HOLE::Clone() const { - HOLE* h = new HOLE( nullptr, m_holeShape->Clone() ); + HOLE* h = new HOLE( m_holeShape->Clone() ); h->SetLayers( Layers() ); h->SetOwner( nullptr ); @@ -131,7 +131,7 @@ void HOLE::Move( const VECTOR2I& delta ) HOLE* HOLE::MakeCircularHole( const VECTOR2I& pos, int radius ) { SHAPE_CIRCLE* circle = new SHAPE_CIRCLE( pos, radius ); - HOLE* hole = new HOLE( nullptr, circle ); + HOLE* hole = new HOLE( circle ); hole->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) ); return hole; diff --git a/pcbnew/router/pns_hole.h b/pcbnew/router/pns_hole.h index 92d5129db6..9e05c2def0 100644 --- a/pcbnew/router/pns_hole.h +++ b/pcbnew/router/pns_hole.h @@ -33,14 +33,18 @@ namespace PNS class HOLE : public ITEM { public: - HOLE( ITEM* aParentPadVia, SHAPE* aShape ) : + HOLE( SHAPE* aShape ) : ITEM( ITEM::HOLE_T ), m_holeShape( aShape ), - m_parentPadVia( aParentPadVia ) + m_parentPadVia( nullptr ) { } - HOLE( const ITEM& aOther ) : ITEM( aOther ) {} + HOLE( const ITEM& aOther ) : + ITEM( aOther ), + m_parentPadVia( nullptr ) + { + } virtual ~HOLE(); diff --git a/pcbnew/router/pns_item.h b/pcbnew/router/pns_item.h index c048968823..5b1e9a2e78 100644 --- a/pcbnew/router/pns_item.h +++ b/pcbnew/router/pns_item.h @@ -128,7 +128,7 @@ public: m_movable = aOther.m_movable; m_kind = aOther.m_kind; m_parent = aOther.m_parent; - m_owner = aOther.m_owner; // fixme: wtf this was null? + m_owner = nullptr; m_marker = aOther.m_marker; m_rank = aOther.m_rank; m_routable = aOther.m_routable; diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 1645d7bb2e..06f3db98c0 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1098,12 +1098,7 @@ std::unique_ptr PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad ) solid->SetOffset( VECTOR2I( offset.x, offset.y ) ); if( aPad->GetDrillSize().x > 0 ) - { - SHAPE_SEGMENT* slot = (SHAPE_SEGMENT*) aPad->GetEffectiveHoleShape()->Clone(); - PNS::HOLE* hole = new PNS::HOLE( solid.get(), slot ); - - solid->SetHole( hole ); - } + solid->SetHole( new PNS::HOLE( aPad->GetEffectiveHoleShape()->Clone() ) ); // We generate a single SOLID for a pad, so we have to treat it as ALWAYS_FLASHED and then // perform layer-specific flashing tests internally. @@ -1176,11 +1171,7 @@ std::unique_ptr PNS_KICAD_IFACE_BASE::syncVia( PCB_VIA* aVia ) via->Mark( PNS::MK_LOCKED ); via->SetIsFree( aVia->GetIsFree() ); - - SHAPE* holeShape = new SHAPE_CIRCLE( aVia->GetPosition(), aVia->GetDrillValue() / 2 ); - PNS::HOLE* viaHole = new PNS::HOLE( via.get(), holeShape ); - - via->SetHole( viaHole ); + via->SetHole( PNS::HOLE::MakeCircularHole( aVia->GetPosition(), aVia->GetDrillValue() / 2 ) ); return via; } diff --git a/pcbnew/router/pns_line.cpp b/pcbnew/router/pns_line.cpp index 3848c9ff17..0ffeebc668 100644 --- a/pcbnew/router/pns_line.cpp +++ b/pcbnew/router/pns_line.cpp @@ -51,6 +51,7 @@ LINE::LINE( const LINE& aOther ) { m_via = aOther.m_via->Clone(); m_via->SetOwner( this ); + m_via->SetNet( m_net ); } m_marker = aOther.m_marker; @@ -82,6 +83,7 @@ LINE& LINE::operator=( const LINE& aOther ) { m_via = aOther.m_via->Clone(); m_via->SetOwner( this ); + m_via->SetNet( m_net ); } m_marker = aOther.m_marker; @@ -1267,11 +1269,7 @@ bool LINE::HasLockedSegments() const void LINE::Clear() { - if( m_via && m_via->BelongsTo( this ) ) - { - delete m_via; - m_via = nullptr; - } + RemoveVia(); m_line.Clear(); } diff --git a/pcbnew/router/pns_solid.h b/pcbnew/router/pns_solid.h index 131cc9ca43..56a6fa14af 100644 --- a/pcbnew/router/pns_solid.h +++ b/pcbnew/router/pns_solid.h @@ -113,19 +113,14 @@ public: virtual void SetHole( HOLE* aHole ) override { - if( m_hole ) - { - assert( m_hole->Owner() == nullptr ); - } + if( m_hole && m_hole->BelongsTo( this ) ) + delete m_hole; m_hole = aHole; - m_hole->SetNet( Net() ); + m_hole->SetParentPadVia( this ); m_hole->SetOwner( this ); - - if( m_hole ) - { - m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different than copper layer set - } + m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different + // than copper layer set } virtual bool HasHole() const override { return m_hole != nullptr; } diff --git a/pcbnew/router/pns_via.h b/pcbnew/router/pns_via.h index 649146b42d..8622d3ef3e 100644 --- a/pcbnew/router/pns_via.h +++ b/pcbnew/router/pns_via.h @@ -54,12 +54,12 @@ public: LINKED_ITEM( VIA_T ), m_hole( nullptr ) { - m_diameter = 2; // Dummy value - m_drill = 0; + m_diameter = 2; // Dummy value + m_drill = 1; // Dummy value m_viaType = VIATYPE::THROUGH; m_isFree = false; m_isVirtual = false; - SetHole( HOLE::MakeCircularHole( m_pos, m_diameter / 2 ) ); + SetHole( HOLE::MakeCircularHole( m_pos, m_drill / 2 ) ); } VIA( const VECTOR2I& aPos, const LAYER_RANGE& aLayers, int aDiameter, int aDrill, @@ -171,15 +171,14 @@ public: virtual void SetHole( HOLE* aHole ) override { - if( m_hole && m_hole->Owner() == this ) + if( m_hole && m_hole->BelongsTo( this ) ) delete m_hole; m_hole = aHole; m_hole->SetParentPadVia( this ); m_hole->SetOwner( this ); - - if( m_hole ) - m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different than copper layer set + m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different + // than copper layer set } virtual bool HasHole() const override { return true; }