From 1c46c6da9dddbd31cafabef4070a6c1a6db91851 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 24 Dec 2019 16:30:33 +0100 Subject: [PATCH] - more leaks plugged, plus rerouting exception messages to the log window. --- source/common/gamecontrol.cpp | 27 ++++++++++++--------------- source/common/searchpaths.cpp | 1 + source/platform/win32/i_main.cpp | 2 +- source/platform/win32/i_system.h | 1 + 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index f33da2aeb..554ffc7f4 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -285,13 +285,6 @@ void I_StartupJoysticks(); void I_ShutdownInput(); int RunGame(); -void ShutdownSystem() -{ - Mus_Stop(); - if (soundEngine) delete soundEngine; - I_ShutdownInput(); -} - int GameMain() { int r; @@ -299,24 +292,28 @@ int GameMain() { r = RunGame(); } - catch (const std::runtime_error & err) - { - // shut down critical systems before showing a message box. - ShutdownSystem(); - wm_msgbox("Error", "%s", err.what()); - return 3; - } catch (const ExitEvent & exit) { // Just let the rest of the function execute. r = exit.Reason(); } - ShutdownSystem(); + catch (const std::exception & err) + { + // shut down critical systems before showing a message box. + I_ShowFatalError(err.what()); + r = -1; + } + S_StopMusic(true); + if (soundEngine) delete soundEngine; + I_ShutdownInput(); G_SaveConfig(); C_DeinitConsole(); + V_ClearFonts(); + if (gi) delete gi; #ifndef NETCODE_DISABLE if (gHaveNetworking) enet_deinitialize(); #endif + DeleteStartupScreen(); if (Args) delete Args; return r; } diff --git a/source/common/searchpaths.cpp b/source/common/searchpaths.cpp index 1001a2ff8..0c464bd3b 100644 --- a/source/common/searchpaths.cpp +++ b/source/common/searchpaths.cpp @@ -983,6 +983,7 @@ TArray GrpScan() break; } } + delete resf; } } } diff --git a/source/platform/win32/i_main.cpp b/source/platform/win32/i_main.cpp index a4afcfcea..7597b68ba 100644 --- a/source/platform/win32/i_main.cpp +++ b/source/platform/win32/i_main.cpp @@ -1172,7 +1172,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int _CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF); // Use this to break at a specific allocation number. - //_crtBreakAlloc = 167; + //_crtBreakAlloc = 10563; #endif int ret = DoMain (hInstance); diff --git a/source/platform/win32/i_system.h b/source/platform/win32/i_system.h index 0cd3e9444..a6dd88ea6 100644 --- a/source/platform/win32/i_system.h +++ b/source/platform/win32/i_system.h @@ -45,6 +45,7 @@ void I_Init (void); // Return a seed value for the RNG. unsigned int I_MakeRNGSeed(); +void I_ShowFatalError(const char* msg); //