From 83624acfd21401cf3e0c50727423c4fddaf7694b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 8 Aug 2023 12:34:57 +0100 Subject: [PATCH] Allow GetLayer() to be used with single-layer zones. Also fixes a bug in GetFirstLayer() where we were checking m_layerSet.size() (which is always 60) rather than m_layerSet.count() (which is the number of set layers). Fixes https://gitlab.com/kicad/code/kicad/-/issues/15233 (cherry picked from commit 8bb895373a2fbc2805e89a4c28d1957da7436367) --- common/layer_id.cpp | 3 +++ pcbnew/zone.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/layer_id.cpp b/common/layer_id.cpp index 3b21389880..7153df49d6 100644 --- a/common/layer_id.cpp +++ b/common/layer_id.cpp @@ -32,6 +32,9 @@ wxString LayerName( int aLayer ) switch( aLayer ) { // PCB_LAYER_ID + case UNDEFINED_LAYER: return _( "undefined" ); + + // Copper case F_Cu: return wxT( "F.Cu" ); case In1_Cu: return wxT( "In1.Cu" ); case In2_Cu: return wxT( "In2.Cu" ); diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 94fb6769e0..7bdf7a38fd 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -244,13 +244,16 @@ VECTOR2I ZONE::GetPosition() const PCB_LAYER_ID ZONE::GetLayer() const { - return BOARD_ITEM::GetLayer(); + if( m_layerSet.count() == 1 ) + return m_layerSet.UIOrder()[0]; + else + return UNDEFINED_LAYER; } PCB_LAYER_ID ZONE::GetFirstLayer() const { - if( m_layerSet.size() ) + if( m_layerSet.count() ) return m_layerSet.UIOrder()[0]; else return UNDEFINED_LAYER;