netlist_exporter_spice: fix crash when re-run the simulator after a schematic change.

Fixes #12142
https://gitlab.com/kicad/code/kicad/issues/12142
This commit is contained in:
jean-pierre charras 2022-08-09 18:33:54 +02:00
parent ba7a06f52e
commit 4f7d7013e0
1 changed files with 4 additions and 3 deletions

View File

@ -97,6 +97,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
m_nets.clear(); m_nets.clear();
m_items.clear(); m_items.clear();
m_libParts.clear();
for( unsigned sheetIndex = 0; sheetIndex < m_schematic->GetSheets().size(); ++sheetIndex ) for( unsigned sheetIndex = 0; sheetIndex < m_schematic->GetSheets().size(); ++sheetIndex )
{ {
@ -226,7 +227,7 @@ void NETLIST_EXPORTER_SPICE::readLibraryField( SCH_SYMBOL& aSymbol, SPICE_ITEM&
if( field ) if( field )
path = field->GetShownText(); path = field->GetShownText();
if( path.IsEmpty() ) if( path.IsEmpty() )
return; return;
@ -240,7 +241,7 @@ void NETLIST_EXPORTER_SPICE::readLibraryField( SCH_SYMBOL& aSymbol, SPICE_ITEM&
{ {
DisplayErrorMessage( nullptr, wxString::Format( "Failed reading model library '%s'.", DisplayErrorMessage( nullptr, wxString::Format( "Failed reading model library '%s'.",
absolutePath ), absolutePath ),
e.What() ); e.What() );
} }
aItem.libraryPath = path; aItem.libraryPath = path;
@ -366,7 +367,7 @@ void NETLIST_EXPORTER_SPICE::writeInclude( OUTPUTFORMATTER& aFormatter, unsigned
// Look for the library in known search locations. // Look for the library in known search locations.
fullPath = ResolveFile( expandedPath, &Pgm().GetLocalEnvVariables(), fullPath = ResolveFile( expandedPath, &Pgm().GetLocalEnvVariables(),
&m_schematic->Prj() ); &m_schematic->Prj() );
if( fullPath.IsEmpty() ) if( fullPath.IsEmpty() )
{ {
DisplayErrorMessage( nullptr, DisplayErrorMessage( nullptr,