← Back to team overview

kicad-developers team mailing list archive

[PATCH] Multiple Zone bugfix

 

​The attached patch fixes two issues with t​he multiple zone handling when
duplicating.  One is a segfault when accessing SetLayerSet() on a layer
that doesn't have a copper zone assigned and the second ensures that the
layerset is propagated to new layers when cloning and assigning.

-S
From 6694f2f78b3101605d5b9bb1549d086247b93c6d Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@xxxxxxxxxxx>
Date: Fri, 29 Sep 2017 09:49:09 -0700
Subject: [PATCH 1/1] pcbnew: multiple keepout zone bug fixes

- Fixes segfault in ZONE_CONTAINER::SetLayerSet
- Copies layerset when using assignment and new()
---
 pcbnew/class_zone.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp
index 410eb9fa0..6029d937e 100644
--- a/pcbnew/class_zone.cpp
+++ b/pcbnew/class_zone.cpp
@@ -105,6 +105,7 @@ ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
     m_hatchPitch = aZone.m_hatchPitch;
     m_HatchLines = aZone.m_HatchLines;
 
+    SetLayerSet( aZone.GetLayerSet() );
     SetLocalFlags( aZone.GetLocalFlags() );
 }
 
@@ -133,6 +134,8 @@ ZONE_CONTAINER& ZONE_CONTAINER::operator=( const ZONE_CONTAINER& aOther )
     m_FillSegmList.clear();
     m_FillSegmList = aOther.m_FillSegmList;
 
+    SetLayerSet( aOther.GetLayerSet() );
+
     return *this;
 }
 
@@ -213,17 +216,17 @@ void ZONE_CONTAINER::SetLayer( PCB_LAYER_ID aLayer )
 
 void ZONE_CONTAINER::SetLayerSet( LSET aLayerSet )
 {
-    if( aLayerSet.count() == 0 )
-    {
-        return;
-    }
-
     if( GetIsKeepout() )
     {
         // Keepouts can only exist on copper layers
         aLayerSet &= LSET::AllCuMask();
     }
 
+    if( aLayerSet.count() == 0 )
+    {
+        return;
+    }
+
     m_layerSet = aLayerSet;
 
     // Set the single layer to the first selected layer
-- 
2.11.0


Follow ups