Skip to content

Commit

Permalink
free the WidgetResources file on shutdown to reduce the number of rep…
Browse files Browse the repository at this point in the history
…orted memory leaks.
  • Loading branch information
coelckers committed Jan 6, 2024
1 parent 218a617 commit 9e7785e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/common/widgets/widgetresourcedata.cpp
Expand Up @@ -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<uint8_t> LoadFile(const std::string& name)
{
auto lump = WidgetResources->FindEntry(name.c_str());
Expand Down
2 changes: 2 additions & 0 deletions source/core/gamecontrol.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -663,6 +664,7 @@ int GameMain()
gi = nullptr;
}
DeleteStartupScreen();
CloseWidgetResources();
PClass::StaticShutdown();
C_UninitCVars();
if (Args) delete Args;
Expand Down

0 comments on commit 9e7785e

Please sign in to comment.