From a3da0b9af692628e7c1e529e3a937c32dd74c80f Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Wed, 15 Jun 2022 19:47:29 +0100 Subject: [PATCH] CADSTAR Schematic: Load symbols even if part definition is incomplete Fixes https://gitlab.com/kicad/code/kicad/-/issues/11671 (cherry picked from commit 8725c3a35f504c8314128dccd018c8a95239ccb7) --- .../cadstar/cadstar_sch_archive_loader.cpp | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index 2cc821ef46..e9a5b80024 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -369,9 +369,6 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary() PART_ID partID = partPair.first; PART part = partPair.second; - if( part.Definition.GateSymbols.size() == 0 ) - continue; - wxString escapedPartName = EscapeString( part.Name, CTX_LIBID ); LIB_SYMBOL* kiPart = new LIB_SYMBOL( escapedPartName ); @@ -383,7 +380,6 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary() GATE_ID gateID = gatePair.first; PART::DEFINITION::GATE gate = gatePair.second; SYMDEF_ID symbolID = getSymDefFromName( gate.Name, gate.Alternate ); - m_partSymbolsMap.insert( { { partID, gateID }, symbolID } ); if( symbolID.IsEmpty() ) { @@ -400,10 +396,11 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary() break; } + m_partSymbolsMap.insert( { { partID, gateID }, symbolID } ); loadSymDefIntoLibrary( symbolID, &part, gateID, kiPart ); } - if( ok ) + if( ok && part.Definition.GateSymbols.size() != 0 ) { ( *m_plugin )->SaveSymbol( m_libraryFileName.GetFullPath(), kiPart ); @@ -414,8 +411,19 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary() } else { + if( part.Definition.GateSymbols.size() == 0 ) + { + m_reporter->Report( + wxString::Format( _( "Part definition '%s' has an incomplete definition (no" + " symbol definitions are associated with it). The part" + " has not been loaded into the KiCad library." ), + part.Name ), + RPT_SEVERITY_WARNING ); + } + // Don't save in the library, but still keep it cached as some of the units might have - // been loaded correctly (saving us time later on) + // been loaded correctly (saving us time later on), plus the part definition contains + // the part name, which is important to load m_partMap.insert( { partID, kiPart } ); } @@ -1602,17 +1610,19 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef loadLibraryField( attrVal ); } - wxString fpNameInLibrary = generateLibName( footprintRefName, footprintAlternateName ); - wxArrayString fpFilters; - fpFilters.Add( fpNameInLibrary ); + wxString fpNameInLibrary = generateLibName( footprintRefName, footprintAlternateName ); - aSymbol->SetFPFilters( fpFilters ); + if( !fpNameInLibrary.IsEmpty() ) + { + wxArrayString fpFilters; + fpFilters.Add( fpNameInLibrary ); + aSymbol->SetFPFilters( fpFilters ); - // Assume that the PCB footprint library name will be the same as the schematic filename - wxFileName schFilename( Filename ); - wxString libName = schFilename.GetName(); - - aSymbol->GetFootprintField().SetText( libName + wxT( ":" ) + fpNameInLibrary ); + // Assume that the PCB footprint library name will be the same as the schematic filename + wxFileName schFilename( Filename ); + wxString libName = schFilename.GetName(); + aSymbol->GetFootprintField().SetText( libName + wxT( ":" ) + fpNameInLibrary ); + } } if( aCadstarPart && aCadstarPart->Definition.HidePinNames )