From 67e06bb4ac837485488ccaa9c9d3be0f78c7f17e Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sat, 8 Apr 2017 17:09:58 +0200 Subject: [PATCH] winmain.c, bug fix, #315 ngspice under windows 10 shows exception on quit https://sourceforge.net/p/ngspice/bugs/315/ longjmp() creates segfault under Windows 10 (VS and MINGW) somewhere when MainWindowProc() is processing the WM_CLOSE message. Instead of raising SIGINT, directly call cp_doquit(). return 0 if "askquit" is set and the user declines to "quit". This continues the simulation, if still active. --- src/winmain.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/winmain.c b/src/winmain.c index e1fdf0f9b..73e7bf7eb 100644 --- a/src/winmain.c +++ b/src/winmain.c @@ -97,6 +97,8 @@ extern bool ft_ngdebug; /* some additional debug info printed */ extern bool ft_batchmode; extern FILE *flogp; /* definition see xmain.c, stdout redirected to file */ +extern void cp_doquit(void); + #include "winmain.h" /* -------------------------------------------------------- */ @@ -506,11 +508,8 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) goto DEFAULT_AFTER; case WM_CLOSE: - /* Put Spice commmand "Quit" to end the program into the text buffer */ - PostSpiceCommand("quit"); - - /* If simulation is running, set a breakpoint */ - raise (SIGINT); + cp_doquit(); + /* continue if the user declined the 'quit' command */ return 0; case WM_SIZE: