← Back to team overview

kicad-developers team mailing list archive

Re: [FEATURE] Add keepout areas in footprints

 

Le 16/10/2017 à 15:08, Oliver Walters a écrit :
> By 'segfault' I obviously meant assertion error. The Type() calls are returning: 
> 
> a) PCB_MODULE_T
> b) PCB_ZONE_AREA_T
> 
> Oliver

Hi Oliver,

Please, apply this patch to your working tree.

Currently, there is an issue when storing keepout area layers list in fp in files, when a board has
only 2 layers:
the option "internal layers" is lost, because there is no internal layer.
Therefore the current way to store this option in file is not good.

-- 
Jean-Pierre CHARRAS
 pcbnew/board_commit.cpp | 25 +++++++++++--------------
 pcbnew/class_module.cpp |  2 ++
 pcbnew/kicad_plugin.cpp |  4 ++--
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp
index 85033ca..df2a192 100644
--- a/pcbnew/board_commit.cpp
+++ b/pcbnew/board_commit.cpp
@@ -82,20 +82,17 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
             if( ent.m_item->Type() != PCB_MODULE_T )
                 ent.m_item = ent.m_item->GetParent();
 
-            //if( ent.m_copy->Type() != PCB_MODULE_T )
-            //    ent.m_copy = ent.m_copy->GetParent();
-
             // We have not saved the module yet, so let's create an entry
             if( savedModules.count( ent.m_item ) == 0 )
             {
                 if( !ent.m_copy )
                 {
-                    assert( changeType != CHT_MODIFY );     // too late to make a copy..
+                    wxASSERT( changeType != CHT_MODIFY );     // too late to make a copy..
                     ent.m_copy = ent.m_item->Clone();
                 }
 
-                assert( ent.m_item->Type() == PCB_MODULE_T );
-                //assert( ent.m_copy->Type() == PCB_MODULE_T );
+                wxASSERT( ent.m_item->Type() == PCB_MODULE_T );
+                wxASSERT( ent.m_copy->Type() == PCB_MODULE_T );
 
                 if( aCreateUndoEntry )
                 {
@@ -135,7 +132,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
                 else
                 {
                     // modules inside modules are not supported yet
-                    assert( boardItem->Type() != PCB_MODULE_T );
+                    wxASSERT( boardItem->Type() != PCB_MODULE_T );
 
                     boardItem->SetParent( board->m_Modules.GetFirst() );
                     if( !( changeFlags & CHT_DONE ) )
@@ -186,7 +183,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
                                 break;
 
                             default:
-                                assert( false );
+                                wxASSERT( false );
                                 break;
                         }
                     }
@@ -198,7 +195,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
                         if( !( changeFlags & CHT_DONE ) )
                         {
                             MODULE* module = static_cast<MODULE*>( boardItem->GetParent() );
-                            assert( module && module->Type() == PCB_MODULE_T );
+                            wxASSERT( module && module->Type() == PCB_MODULE_T );
                             module->Delete( boardItem );
                         }
 
@@ -228,7 +225,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
                 case PCB_MODULE_T:
                 {
                     // There are no modules inside a module yet
-                    assert( !m_editModules );
+                    wxASSERT( !m_editModules );
 
                     MODULE* module = static_cast<MODULE*>( boardItem );
                     module->ClearFlags();
@@ -245,7 +242,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
                 break;
 
                 default:                        // other types do not need to (or should not) be handled
-                    assert( false );
+                    wxASSERT( false );
                     break;
                 }
                 break;
@@ -256,7 +253,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
                 if( !m_editModules && aCreateUndoEntry )
                 {
                     ITEM_PICKER itemWrapper( boardItem, UR_CHANGED );
-                    assert( ent.m_copy );
+                    wxASSERT( ent.m_copy );
                     itemWrapper.SetLink( ent.m_copy );
                     undoList.PushItem( itemWrapper );
                 }
@@ -274,7 +271,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
             }
 
             default:
-                assert( false );
+                wxASSERT( false );
                 break;
         }
     }
@@ -384,7 +381,7 @@ void BOARD_COMMIT::Revert()
         }
 
         default:
-            assert( false );
+            wxASSERT( false );
             break;
         }
     }
diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp
index b5349dc..2518766 100644
--- a/pcbnew/class_module.cpp
+++ b/pcbnew/class_module.cpp
@@ -219,6 +219,8 @@ MODULE& MODULE::operator=( const MODULE& aOther )
         }
     }
 
+    m_Zones.DeleteAll();
+
     for( ZONE_CONTAINER* zone = aOther.m_Zones; zone; zone = zone->Next() )
     {
         Add( new ZONE_CONTAINER( *zone ) );
diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp
index ca5cf3d..4802ad3 100644
--- a/pcbnew/kicad_plugin.cpp
+++ b/pcbnew/kicad_plugin.cpp
@@ -1291,8 +1291,8 @@ void PCB_IO::formatLayers( LSET aLayerMask, int aNestLevel ) const
         aLayerMask &= ~fr_bk;
     }
 
-    // All inner copper layers are selected
-    if( ( aLayerMask & cu_internal) == cu_internal )
+    // All inner copper layers are selected (when inner layers exist)
+    if( cu_internal.any() && ( aLayerMask & cu_internal) == cu_internal )
     {
         output += " *.In.Cu";
         aLayerMask &= ~cu_internal;

Follow ups

References