diff --git a/src/frontend/display.c b/src/frontend/display.c index 856abbe78..fa754205b 100644 --- a/src/frontend/display.c +++ b/src/frontend/display.c @@ -419,7 +419,8 @@ int DevSwitch(char *devname) } else { - dispdev->Close(); + if (dispdev) + dispdev->Close(); dispdev = lastdev; lastdev = NULL; diff --git a/src/frontend/misccoms.c b/src/frontend/misccoms.c index 2ab436c97..4083764af 100644 --- a/src/frontend/misccoms.c +++ b/src/frontend/misccoms.c @@ -10,9 +10,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ftehelp.h" #include "ngspice/hlpdefs.h" #include "misccoms.h" +#include "postcoms.h" #include "circuits.h" #include "variable.h" #include "plotting/graf.h" +#include "display.h" #ifdef HAVE_GNUREADLINE #include @@ -51,6 +53,12 @@ com_quit(wordlist *wl) /* start to clean up the mess */ + { + wordlist *t = wl_cons(copy("all"), NULL); + com_destroy(t); + wl_free(t); + } + #ifdef EXPERIMENTAL_CODE /* Destroy CKT when quit. Add by Gong Ding, gdiso@ustc.edu */ if (!ft_nutmeg) { @@ -61,6 +69,9 @@ com_quit(wordlist *wl) } #endif + DevSwitch(NULL); + DevSwitch(NULL); + /* then go away */ byemesg(); exit(exitcode); diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index 805c739ca..e7a9e791d 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -507,7 +507,16 @@ X11_NewViewport(GRAPH *graph) int X11_Close(void) { - XCloseDisplay(display); + // don't, this has never been mapped, there is no window ... + // XtUnmapWidget(toplevel); + XtDestroyWidget(toplevel); + + XtAppContext app = XtDisplayToApplicationContext(display); + XtDestroyApplicationContext(app); + + // don't, XtDestroyApplicationContext(app) seems to have done that + // XCloseDisplay(display); + return 0; } @@ -909,7 +918,10 @@ RemoveWindow(GRAPH *graph) /* Iplots are done asynchronously */ DEVDEP(graph).isopen = 0; /* MW. Not sure but DestroyGraph might free() to much - try Xt...() first */ + XtUnmapWidget(DEVDEP(graph).shell); XtDestroyWidget(DEVDEP(graph).shell); + XFreeFont(display, DEVDEP(graph).font); + XFreeGC(display, DEVDEP(graph).gc); } if (graph == currentgraph)