diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp index de0b68a0d7..f05d17a9dd 100644 --- a/eeschema/sim/ngspice.cpp +++ b/eeschema/sim/ngspice.cpp @@ -39,7 +39,9 @@ NGSPICE::NGSPICE() #else m_dll = new wxDynamicLibrary( "libngspice.so" ); #endif - assert( m_dll ); + + if( !m_dll || !m_dll->IsLoaded() ) + throw std::runtime_error( "Missing ngspice shared library" ); // Obtain function pointers m_ngSpice_Init = (ngSpice_Init) m_dll->GetSymbol( "ngSpice_Init" ); diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 174ae3403f..be57e88ae8 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -120,6 +120,10 @@ void SIM_PLOT_FRAME::StartSimulation() /// @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() ); diff --git a/eeschema/sim/spice_simulator.cpp b/eeschema/sim/spice_simulator.cpp index f888c31a45..22bab368bd 100644 --- a/eeschema/sim/spice_simulator.cpp +++ b/eeschema/sim/spice_simulator.cpp @@ -24,8 +24,19 @@ #include "ngspice.h" +#include + SPICE_SIMULATOR* SPICE_SIMULATOR::CreateInstance( const std::string& ) { - return new NGSPICE; + try + { + return new NGSPICE; + } + catch( std::exception& e ) + { + DisplayError( NULL, e.what() ); + } + + return NULL; }