- 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();
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;
}

View file

@ -983,6 +983,7 @@ TArray<GrpEntry> GrpScan()
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);
// Use this to break at a specific allocation number.
//_crtBreakAlloc = 167;
//_crtBreakAlloc = 10563;
#endif
int ret = DoMain (hInstance);

View file

@ -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);
//