Spice simulator: changed NGSPICE instance type to shared_ptr
It was yet another time when I tried to free a singleton pointer. Let's make clear it is not meant to be freed manually.
This commit is contained in:
parent
50053e7f27
commit
61e42ba392
|
@ -286,7 +286,7 @@ private:
|
||||||
|
|
||||||
SCH_EDIT_FRAME* m_schematicFrame;
|
SCH_EDIT_FRAME* m_schematicFrame;
|
||||||
std::unique_ptr<NETLIST_EXPORTER_PSPICE_SIM> m_exporter;
|
std::unique_ptr<NETLIST_EXPORTER_PSPICE_SIM> m_exporter;
|
||||||
SPICE_SIMULATOR* m_simulator;
|
std::shared_ptr<SPICE_SIMULATOR> m_simulator;
|
||||||
SIM_THREAD_REPORTER* m_reporter;
|
SIM_THREAD_REPORTER* m_reporter;
|
||||||
|
|
||||||
typedef std::map<wxString, TRACE_DESC> TRACE_MAP;
|
typedef std::map<wxString, TRACE_DESC> TRACE_MAP;
|
||||||
|
|
|
@ -26,14 +26,14 @@
|
||||||
|
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
|
||||||
SPICE_SIMULATOR* SPICE_SIMULATOR::CreateInstance( const std::string& )
|
std::shared_ptr<SPICE_SIMULATOR> SPICE_SIMULATOR::CreateInstance( const std::string& )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
static NGSPICE* ngspiceInstance = nullptr;
|
static std::shared_ptr<SPICE_SIMULATOR> ngspiceInstance;
|
||||||
|
|
||||||
if( !ngspiceInstance )
|
if( !ngspiceInstance )
|
||||||
ngspiceInstance = new NGSPICE;
|
ngspiceInstance.reset( new NGSPICE );
|
||||||
|
|
||||||
return ngspiceInstance;
|
return ngspiceInstance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class SPICE_REPORTER;
|
class SPICE_REPORTER;
|
||||||
|
class SPICE_SIMULATOR;
|
||||||
|
|
||||||
typedef std::complex<double> COMPLEX;
|
typedef std::complex<double> COMPLEX;
|
||||||
|
|
||||||
|
@ -42,7 +44,7 @@ public:
|
||||||
virtual ~SPICE_SIMULATOR() {}
|
virtual ~SPICE_SIMULATOR() {}
|
||||||
|
|
||||||
///> Creates a simulator instance of particular type (currently only ngspice is handled)
|
///> Creates a simulator instance of particular type (currently only ngspice is handled)
|
||||||
static SPICE_SIMULATOR* CreateInstance( const std::string& aName );
|
static std::shared_ptr<SPICE_SIMULATOR> CreateInstance( const std::string& aName );
|
||||||
|
|
||||||
///> Intializes the simulator
|
///> Intializes the simulator
|
||||||
virtual void Init() = 0;
|
virtual void Init() = 0;
|
||||||
|
|
Loading…
Reference in New Issue