Eeschema, spice sim: fix a crash when no value is available.

onSimFinished() try to analyse the list of plots, but did not test
if there is available data before using it.
Fixes #8169
https://gitlab.com/kicad/code/kicad/issues/8169
This commit is contained in:
jean-pierre charras 2021-04-14 21:01:39 +02:00
parent 7c64dba333
commit e5dd54e05a
2 changed files with 6 additions and 2 deletions

View File

@ -166,7 +166,7 @@ vector<double> NGSPICE::GetRealPlot( const string& aName, int aMaxLen )
{ {
for( int i = 0; i < length; i++ ) for( int i = 0; i < length; i++ )
{ {
assert( vi->v_compdata[i].cx_imag == 0.0 ); wxASSERT( vi->v_compdata[i].cx_imag == 0.0 );
data.push_back( vi->v_compdata[i].cx_real ); data.push_back( vi->v_compdata[i].cx_real );
} }
} }

View File

@ -1539,8 +1539,12 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent )
for( const auto& vec : m_simulator->AllPlots() ) for( const auto& vec : m_simulator->AllPlots() )
{ {
double val = m_simulator->GetRealPlot( vec, 1 ).at( 0 ); std::vector<double> val_list = m_simulator->GetRealPlot( vec, 1 );
if( val_list.size() == 0 ) // The list of values can be empty!
continue;
double val = val_list.at( 0 );
wxString outLine, signal; wxString outLine, signal;
SIM_PLOT_TYPE type = m_exporter->VectorToSignal( vec, signal ); SIM_PLOT_TYPE type = m_exporter->VectorToSignal( vec, signal );