From 9e7785e44c1cd45df08b979030f6bdf8355fc557 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Jan 2024 14:42:36 +0100 Subject: [PATCH] free the WidgetResources file on shutdown to reduce the number of reported memory leaks. --- source/common/widgets/widgetresourcedata.cpp | 5 +++++ source/core/gamecontrol.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/source/common/widgets/widgetresourcedata.cpp b/source/common/widgets/widgetresourcedata.cpp index 84822fc86..fd416e1d1 100644 --- a/source/common/widgets/widgetresourcedata.cpp +++ b/source/common/widgets/widgetresourcedata.cpp @@ -12,6 +12,11 @@ void InitWidgetResources(const char* filename) I_FatalError("Unable to open %s", filename); } +void CloseWidgetResources() +{ + if (WidgetResources) delete WidgetResources; +} + static std::vector LoadFile(const std::string& name) { auto lump = WidgetResources->FindEntry(name.c_str()); diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 7357eb934..21fa5df7e 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -90,6 +90,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. void LoadHexFont(const char* filename); void InitWidgetResources(const char* basewad); +void CloseWidgetResources(); CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -663,6 +664,7 @@ int GameMain() gi = nullptr; } DeleteStartupScreen(); + CloseWidgetResources(); PClass::StaticShutdown(); C_UninitCVars(); if (Args) delete Args;