From 9396735733bbd30e1fad10157e98964c3b27bebc Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 2 Mar 2022 10:15:41 -0800 Subject: [PATCH] Select the copper layer before processing If we are converting to tracks, the copper layer needs to be selected before any other elements are processed, otherwise, we end up with the default undefined layer Fixes https://gitlab.com/kicad/code/kicad/issues/11025 --- pcbnew/tools/convert_tool.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/pcbnew/tools/convert_tool.cpp b/pcbnew/tools/convert_tool.cpp index e296ed7809..608fca0997 100644 --- a/pcbnew/tools/convert_tool.cpp +++ b/pcbnew/tools/convert_tool.cpp @@ -644,7 +644,7 @@ int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent ) FOOTPRINT_EDIT_FRAME* fpEditor = dynamic_cast( m_frame ); FOOTPRINT* footprint = nullptr; PCB_LAYER_ID targetLayer = m_frame->GetActiveLayer(); - PCB_LAYER_ID copperLayer = UNSELECTED_LAYER; + PCB_LAYER_ID copperLayer = F_Cu; BOARD_ITEM_CONTAINER* parent = frame->GetModel(); if( fpEditor ) @@ -685,6 +685,20 @@ int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent ) return false; }; + if( aEvent.IsAction( &PCB_ACTIONS::convertToTracks ) ) + { + if( !IsCopperLayer( targetLayer ) ) + { + if( copperLayer == UNSELECTED_LAYER ) + copperLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() ); + + if( copperLayer == UNDEFINED_LAYER ) // User canceled + return true; + + targetLayer = copperLayer; + } + } + for( EDA_ITEM* item : selection ) { if( handleGraphicSeg( item ) ) @@ -721,19 +735,6 @@ int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent ) } else { - - - if( !IsCopperLayer( targetLayer ) ) - { - if( copperLayer == UNSELECTED_LAYER ) - copperLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() ); - - if( copperLayer == UNDEFINED_LAYER ) // User canceled - continue; - - targetLayer = copperLayer; - } - // I am really unsure converting a polygon to "tracks" (i.e. segments on // copper layers) make sense for footprints, but anyway this code exists if( fpEditor )