diff --git a/eeschema/sim/sim_plot_frame.h b/eeschema/sim/sim_plot_frame.h index b4f93b214d..54ee7404a8 100644 --- a/eeschema/sim/sim_plot_frame.h +++ b/eeschema/sim/sim_plot_frame.h @@ -286,7 +286,7 @@ private: SCH_EDIT_FRAME* m_schematicFrame; std::unique_ptr m_exporter; - SPICE_SIMULATOR* m_simulator; + std::shared_ptr m_simulator; SIM_THREAD_REPORTER* m_reporter; typedef std::map TRACE_MAP; diff --git a/eeschema/sim/spice_simulator.cpp b/eeschema/sim/spice_simulator.cpp index 8340f9e29f..28670b87fc 100644 --- a/eeschema/sim/spice_simulator.cpp +++ b/eeschema/sim/spice_simulator.cpp @@ -26,14 +26,14 @@ #include -SPICE_SIMULATOR* SPICE_SIMULATOR::CreateInstance( const std::string& ) +std::shared_ptr SPICE_SIMULATOR::CreateInstance( const std::string& ) { try { - static NGSPICE* ngspiceInstance = nullptr; + static std::shared_ptr ngspiceInstance; if( !ngspiceInstance ) - ngspiceInstance = new NGSPICE; + ngspiceInstance.reset( new NGSPICE ); return ngspiceInstance; } diff --git a/eeschema/sim/spice_simulator.h b/eeschema/sim/spice_simulator.h index af5250405a..a18bf91a05 100644 --- a/eeschema/sim/spice_simulator.h +++ b/eeschema/sim/spice_simulator.h @@ -30,8 +30,10 @@ #include #include #include +#include class SPICE_REPORTER; +class SPICE_SIMULATOR; typedef std::complex 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 CreateInstance( const std::string& aName ); ///> Intializes the simulator virtual void Init() = 0;