From 462587fb494cb923c600df9e6f41171bc2fb6830 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Wed, 4 Oct 2023 20:22:26 +0200 Subject: [PATCH] In Win32, Ctrl-C on console app does not do leaks check anymore --- uppsrc/Core/App.cpp | 14 ++++++++++++++ uppsrc/Core/heapdbg.cpp | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/uppsrc/Core/App.cpp b/uppsrc/Core/App.cpp index 7cc604fb2..9a8edc8f0 100644 --- a/uppsrc/Core/App.cpp +++ b/uppsrc/Core/App.cpp @@ -531,6 +531,16 @@ void AppInit__(int argc, const char **argv, const char **envptr) #if defined(PLATFORM_WIN32) +#ifdef _DEBUG +static BOOL WINAPI s_consoleCtrlHandler(DWORD signal) { + if(signal == CTRL_C_EVENT) { + extern bool NoMemoryLeaksCheck; + NoMemoryLeaksCheck = true; + } + return FALSE; +} +#endif + void AppInitEnvironment__() { SetLanguage(LNG_('E', 'N', 'U', 'S')); @@ -567,6 +577,10 @@ void AppInitEnvironment__() void AppInit__(int argc, const char **argv) { AppInitEnvironment__(); + +#ifdef _DEBUG + SetConsoleCtrlHandler(s_consoleCtrlHandler, TRUE); +#endif } #endif diff --git a/uppsrc/Core/heapdbg.cpp b/uppsrc/Core/heapdbg.cpp index 8ed864799..2759129af 100644 --- a/uppsrc/Core/heapdbg.cpp +++ b/uppsrc/Core/heapdbg.cpp @@ -225,9 +225,11 @@ void MemoryCheckDebug() while(p != &dbg_live); } +bool NoMemoryLeaksCheck; + void MemoryDumpLeaks() { - if(PanicMode) + if(PanicMode || NoMemoryLeaksCheck) return; #ifdef PLATFORM_MACOS return; // ignore leaks in macos