From 30573beb48aef9f191973e34af0d17636963c80f Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Mon, 4 Mar 2024 16:34:51 +0300 Subject: [PATCH] EasyEDA Std: fix importing footprints from footprint editor. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17264 --- .../pcb_io/easyeda/pcb_io_easyeda_plugin.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp index 650315078c..51e4ccb033 100644 --- a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp +++ b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp @@ -347,9 +347,16 @@ void PCB_IO_EASYEDA::FootprintEnumerate( wxArrayString& aFootprintNames, wxString packageName = wxString::Format( wxS( "Unknown_%s" ), pcbDoc.uuid.value_or( wxS( "Unknown" ) ) ); + std::optional> c_para; + if( pcbDoc.c_para ) + c_para = pcbDoc.c_para; + else if( doc.head.c_para ) + c_para = doc.head.c_para; + + if( c_para ) { - packageName = get_def( *pcbDoc.c_para, wxS( "package" ), packageName ); + packageName = get_def( *c_para, wxS( "package" ), packageName ); } aFootprintNames.Add( packageName ); @@ -477,18 +484,24 @@ FOOTPRINT* PCB_IO_EASYEDA::FootprintLoad( const wxString& aLibraryPath, wxString packageName = wxString::Format( wxS( "Unknown_%s" ), pcbDoc.uuid.value_or( wxS( "Unknown" ) ) ); + std::optional> c_para; + if( pcbDoc.c_para ) + c_para = pcbDoc.c_para; + else if( doc.head.c_para ) + c_para = doc.head.c_para; + + if( c_para ) { - packageName = get_def( *pcbDoc.c_para, wxS( "package" ), packageName ); + packageName = get_def( *c_para, wxS( "package" ), packageName ); if( packageName != aFootprintName ) return nullptr; VECTOR2D origin( doc.head.x, doc.head.y ); - FOOTPRINT* footprint = - parser.ParseFootprint( origin, ANGLE_0, F_Cu, nullptr, *pcbDoc.c_para, - m_loadedFootprints, doc.shape ); + FOOTPRINT* footprint = parser.ParseFootprint( + origin, ANGLE_0, F_Cu, nullptr, *c_para, m_loadedFootprints, doc.shape ); if( !footprint ) return nullptr;