diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index c693195b71..94fd8173da 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -145,6 +145,7 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) m_toolBar->Realize(); m_plotNotebook->SetPageText( 0, _( "Welcome!" ) ); + m_simulator.reset( SPICE_SIMULATOR::CreateInstance( "ngspice" ) ); } @@ -158,6 +159,12 @@ void SIM_PLOT_FRAME::StartSimulation() STRING_FORMATTER formatter; SIM_PLOT_PANEL* plotPanel = CurrentPlot(); + if( !m_simulator ) + { + DisplayError( this, wxT( "Could not create simulator instance" ) ); + return; + } + m_simConsole->Clear(); updateNetlistExporter(); @@ -176,12 +183,6 @@ void SIM_PLOT_FRAME::StartSimulation() return; } - /// @todo is it necessary to recreate simulator every time? - m_simulator.reset( SPICE_SIMULATOR::CreateInstance( "ngspice" ) ); - - if( !m_simulator ) - return; - m_simulator->SetReporter( new SIM_THREAD_REPORTER( this ) ); m_simulator->Init(); m_simulator->LoadNetlist( formatter.GetString() );