diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 8049bd604b..f1b4599832 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -2798,25 +2798,26 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) bool hasDRCViolation( PCB_VIA* aVia, BOARD_ITEM* aOther ) { - DRC_CONSTRAINT constraint; + DRC_CONSTRAINT constraint; + int clearance; + BOARD_CONNECTED_ITEM* connectedItem = dynamic_cast( aOther ); + ZONE* zone = dynamic_cast( aOther ); - if( ( aOther->Type() == PCB_ZONE_T || aOther->Type() == PCB_FP_ZONE_T ) - && static_cast( aOther )->GetIsRuleArea() ) + if( zone && zone->GetIsRuleArea() ) { - ZONE* ruleArea = static_cast( aOther ); - - if( ruleArea->GetDoNotAllowVias() ) - return ruleArea->Outline()->Collide( aVia->GetPosition(), aVia->GetWidth() / 2 ); + if( zone->GetDoNotAllowVias() ) + return zone->Outline()->Collide( aVia->GetPosition(), aVia->GetWidth() / 2 ); return false; } - BOARD_CONNECTED_ITEM* cItem = dynamic_cast( aOther ); + if( connectedItem ) + { + int connectedItemNet = connectedItem->GetNetCode(); - if( cItem && cItem->GetNetCode() == aVia->GetNetCode() ) - return false; - - int clearance; + if( connectedItemNet == 0 || connectedItemNet == aVia->GetNetCode() ) + return false; + } for( PCB_LAYER_ID layer : aOther->GetLayerSet().Seq() ) {