From e9da8c3a005216ee2869d35116177c8e6bf914d0 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 15 Apr 2022 13:19:35 +0200 Subject: [PATCH] Ensure net_code is not used by non copper zones when saving the board file. For some obscure reason, non copper zones inside footprints can have non 0 netcode. Fixes #11395 https://gitlab.com/kicad/code/kicad/issues/11395 --- pcbnew/plugins/kicad/pcb_plugin.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index 318d29a883..582c2e3ea2 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -2049,13 +2049,16 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const { std::string locked = aZone->IsLocked() ? " locked" : ""; - // Save the NET info; For keepout zones, net code and net name are irrelevant + // Save the NET info. + // For keepout and non copper zones, net code and net name are irrelevant // so be sure a dummy value is stored, just for ZONE compatibility // (perhaps netcode and netname should be not stored) + bool has_no_net = aZone->GetIsRuleArea() || !aZone->IsOnCopperLayer(); + m_out->Print( aNestLevel, "(zone%s (net %d) (net_name %s)", locked.c_str(), - aZone->GetIsRuleArea() ? 0 : m_mapping->Translate( aZone->GetNetCode() ), - m_out->Quotew( aZone->GetIsRuleArea() ? wxT("") : aZone->GetNetname() ).c_str() ); + has_no_net ? 0 : m_mapping->Translate( aZone->GetNetCode() ), + m_out->Quotew( has_no_net ? wxT("") : aZone->GetNetname() ).c_str() ); // If a zone exists on multiple layers, format accordingly if( aZone->GetLayerSet().count() > 1 )