From 6e874f4c1ead816e8b8d68f741e7236a21257262 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Tue, 18 Oct 2022 05:17:21 +0200 Subject: [PATCH] Ngspice: Preload a basically empty circuit to avoid error messages Fixes https://gitlab.com/kicad/code/kicad/issues/12481 --- eeschema/sim/ngspice.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp index 64d5c28133..844ddbead3 100644 --- a/eeschema/sim/ngspice.cpp +++ b/eeschema/sim/ngspice.cpp @@ -579,6 +579,19 @@ void NGSPICE::init_dll() Command( "set noaskquit" ); Command( "set nomoremode" ); + // reset and remcirc give an error if no circuit is loaded, so load an empty circuit at the + // start. + + vector lines; + lines.push_back( strdup( "*" ) ); + lines.push_back( strdup( ".end" ) ); + lines.push_back( nullptr ); // Sentinel. + + m_ngSpice_Circ( lines.data() ); + + for( auto line : lines ) + free( line ); + m_initialized = true; }