Display an error message if ngspice DLL is missing

This commit is contained in:
Maciej Suminski 2016-08-11 14:41:48 +02:00
parent 132e30081b
commit d869771f04
3 changed files with 19 additions and 2 deletions

View File

@ -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" );

View File

@ -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() );

View File

@ -24,8 +24,19 @@
#include "ngspice.h"
#include <confirm.h>
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;
}