- more leaks plugged, plus rerouting exception messages to the log window.

This commit is contained in:
Christoph Oelckers 2019-12-24 16:30:33 +01:00
parent 0d908960ed
commit 1c46c6da9d
4 changed files with 15 additions and 16 deletions

View file

@ -285,13 +285,6 @@ void I_StartupJoysticks();
void I_ShutdownInput(); void I_ShutdownInput();
int RunGame(); int RunGame();
void ShutdownSystem()
{
Mus_Stop();
if (soundEngine) delete soundEngine;
I_ShutdownInput();
}
int GameMain() int GameMain()
{ {
int r; int r;
@ -299,24 +292,28 @@ int GameMain()
{ {
r = RunGame(); 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) catch (const ExitEvent & exit)
{ {
// Just let the rest of the function execute. // Just let the rest of the function execute.
r = exit.Reason(); 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(); G_SaveConfig();
C_DeinitConsole(); C_DeinitConsole();
V_ClearFonts();
if (gi) delete gi;
#ifndef NETCODE_DISABLE #ifndef NETCODE_DISABLE
if (gHaveNetworking) enet_deinitialize(); if (gHaveNetworking) enet_deinitialize();
#endif #endif
DeleteStartupScreen();
if (Args) delete Args; if (Args) delete Args;
return r; return r;
} }

View file

@ -983,6 +983,7 @@ TArray<GrpEntry> GrpScan()
break; break;
} }
} }
delete resf;
} }
} }
} }

View file

@ -1172,7 +1172,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int
_CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF); _CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF);
// Use this to break at a specific allocation number. // Use this to break at a specific allocation number.
//_crtBreakAlloc = 167; //_crtBreakAlloc = 10563;
#endif #endif
int ret = DoMain (hInstance); int ret = DoMain (hInstance);

View file

@ -45,6 +45,7 @@ void I_Init (void);
// Return a seed value for the RNG. // Return a seed value for the RNG.
unsigned int I_MakeRNGSeed(); unsigned int I_MakeRNGSeed();
void I_ShowFatalError(const char* msg);
// //