diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 7e6e672878..1288a1a364 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -521,8 +521,10 @@ bool FOOTPRINT::Deserialize( const google::protobuf::Any &aContainer ) for( int layerMsg : footprint.definition().private_layers() ) { - auto layer = static_cast( layerMsg ); - privateLayers.set( FromProtoEnum( layer ) ); + auto layer = FromProtoEnum( static_cast( layerMsg ) ); + + if( layer > UNDEFINED_LAYER ) + privateLayers.set( layer ); } SetPrivateLayers( privateLayers ); diff --git a/pcbnew/pcb_io/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/pcb_io/cadstar/cadstar_pcb_archive_loader.cpp index 1ddea544e0..7a56e2ca65 100644 --- a/pcbnew/pcb_io/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/pcb_io/cadstar/cadstar_pcb_archive_loader.cpp @@ -1046,14 +1046,14 @@ PAD* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad( const COMPONENT_PAD& aCadstarPad, pad->SetLocalSolderPasteMarginRatio( 0.0 ); bool complexPadErrorLogged = false; - for( auto& reassign : csPadcode.Reassigns ) + for( auto& [layer, shape] : csPadcode.Reassigns ) { - PCB_LAYER_ID kiLayer = getKiCadLayer( reassign.first ); - CADSTAR_PAD_SHAPE shape = reassign.second; + PCB_LAYER_ID kiLayer = getKiCadLayer( layer ); if( shape.Size == 0 ) { - padLayerSet.reset( kiLayer ); + if( kiLayer > UNDEFINED_LAYER ) + padLayerSet.reset( kiLayer ); } else { diff --git a/pcbnew/ratsnest/ratsnest_view_item.cpp b/pcbnew/ratsnest/ratsnest_view_item.cpp index a47b0c85b2..b2367914fa 100644 --- a/pcbnew/ratsnest/ratsnest_view_item.cpp +++ b/pcbnew/ratsnest/ratsnest_view_item.cpp @@ -96,7 +96,8 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const // If we are in "other layers off" mode, the active layer is the only visible layer if( rs->m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN ) { - visibleLayers.set( rs->GetPrimaryHighContrastLayer() ); + if( rs->GetPrimaryHighContrastLayer() > UNDEFINED_LAYER ) + visibleLayers.set( rs->GetPrimaryHighContrastLayer() ); } else {