diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index 5024bba5f..c8c868722 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -13,6 +13,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice/ftedev.h" #include "ngspice/ftedebug.h" #include "ngspice/dvec.h" +#include "ngspice/trandefs.h" #include "circuits.h" #include "runcoms2.h" @@ -21,6 +22,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "breakp2.h" #include "plotting/graf.h" #include "spiceif.h" +#include "outitf.h" #include "ngspice/inpdefs.h" @@ -198,6 +200,15 @@ com_remcirc(wordlist *wl) struct line *dd; /*in: the spice deck */ struct circ *p, *prev = NULL; +#ifdef SHARED_MODULE + /* This may happen only with shared ngspice during transient analysis, + if simulation is stopped with 'bg_halt' + and then circuit shall be removed prematurely. */ + TRANan *job = (TRANan *) ft_curckt->ci_ckt->CKTcurJob; + if ((job->JOBtype == 4) && (job->TRANplot)) + SPfrontEnd->OUTendPlot (job->TRANplot); +#endif + NG_IGNORE(wl); if (ft_curckt == NULL) { diff --git a/src/spicelib/analysis/dctran.c b/src/spicelib/analysis/dctran.c index 9f5e1c2bf..0358a1c7d 100644 --- a/src/spicelib/analysis/dctran.c +++ b/src/spicelib/analysis/dctran.c @@ -486,6 +486,7 @@ DCtran(CKTcircuit *ckt, ckt->CKTtime, ckt->CKTfinalTime, ckt->CKTminBreak); #endif SPfrontEnd->OUTendPlot (job->TRANplot); + job->TRANplot = NULL; UPDATE_STATS(0); #ifdef WANT_SENSE2 if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)){