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;
|
||||
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;
|
||||
|
||||
typedef std::map<wxString, TRACE_DESC> TRACE_MAP;
|
||||
|
|
|
@ -26,14 +26,14 @@
|
|||
|
||||
#include <confirm.h>
|
||||
|
||||
SPICE_SIMULATOR* SPICE_SIMULATOR::CreateInstance( const std::string& )
|
||||
std::shared_ptr<SPICE_SIMULATOR> SPICE_SIMULATOR::CreateInstance( const std::string& )
|
||||
{
|
||||
try
|
||||
{
|
||||
static NGSPICE* ngspiceInstance = nullptr;
|
||||
static std::shared_ptr<SPICE_SIMULATOR> ngspiceInstance;
|
||||
|
||||
if( !ngspiceInstance )
|
||||
ngspiceInstance = new NGSPICE;
|
||||
ngspiceInstance.reset( new NGSPICE );
|
||||
|
||||
return ngspiceInstance;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <complex>
|
||||
#include <memory>
|
||||
|
||||
class SPICE_REPORTER;
|
||||
class SPICE_SIMULATOR;
|
||||
|
||||
typedef std::complex<double> COMPLEX;
|
||||
|
||||
|
@ -42,7 +44,7 @@ public:
|
|||
virtual ~SPICE_SIMULATOR() {}
|
||||
|
||||
///> 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
|
||||
virtual void Init() = 0;
|
||||
|
|
Loading…
Reference in New Issue