From f0676cdf019f65f17ea917acb3f65be08718a00f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Oct 2024 10:22:05 +0200 Subject: [PATCH] fixed a few memory leaks --- libraries/ZWidget/src/widgets/lineedit/lineedit.cpp | 2 ++ src/common/scripting/core/types.cpp | 3 ++- src/common/startscreen/startscreen.cpp | 7 +++++++ src/common/startscreen/startscreen.h | 2 +- src/common/widgets/widgetresourcedata.cpp | 1 + src/d_main.cpp | 2 ++ 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libraries/ZWidget/src/widgets/lineedit/lineedit.cpp b/libraries/ZWidget/src/widgets/lineedit/lineedit.cpp index 5c90e68e19..9065ccde4b 100644 --- a/libraries/ZWidget/src/widgets/lineedit/lineedit.cpp +++ b/libraries/ZWidget/src/widgets/lineedit/lineedit.cpp @@ -18,6 +18,8 @@ LineEdit::LineEdit(Widget* parent) : Widget(parent) LineEdit::~LineEdit() { + delete timer; + delete scroll_timer; } bool LineEdit::IsReadOnly() const diff --git a/src/common/scripting/core/types.cpp b/src/common/scripting/core/types.cpp index 8e13dcc521..b70783f3e1 100644 --- a/src/common/scripting/core/types.cpp +++ b/src/common/scripting/core/types.cpp @@ -330,7 +330,8 @@ void PType::StaticInit() TypeVoidPtr = NewPointer(TypeVoid, false); TypeRawFunction = new PPointer; - TypeRawFunction->mDescriptiveName = "Raw Function Pointer"; + TypeRawFunction->mDescriptiveName = "Raw Function Pointer"; + TypeTable.AddType(TypeRawFunction, NAME_None); TypeVMFunction = NewPointer(NewStruct("VMFunction", nullptr, true)); TypeColorStruct = NewStruct("@ColorStruct", nullptr); //This name is intentionally obfuscated so that it cannot be used explicitly. The point of this type is to gain access to the single channels of a color value. TypeStringStruct = NewStruct("Stringstruct", nullptr, true); diff --git a/src/common/startscreen/startscreen.cpp b/src/common/startscreen/startscreen.cpp index b71949f469..56a179526a 100644 --- a/src/common/startscreen/startscreen.cpp +++ b/src/common/startscreen/startscreen.cpp @@ -372,6 +372,13 @@ FStartScreen* GetGameStartScreen(int max_progress) return nullptr; } +FStartScreen::~FStartScreen() +{ + if (StartupTexture) delete StartupTexture; + if (HeaderTexture) delete HeaderTexture; + if (NetTexture) delete NetTexture; +} + //========================================================================== // // ST_Util_ClearBlock diff --git a/src/common/startscreen/startscreen.h b/src/common/startscreen/startscreen.h index afac6c7594..c90d092f95 100644 --- a/src/common/startscreen/startscreen.h +++ b/src/common/startscreen/startscreen.h @@ -70,7 +70,7 @@ protected: FGameTexture* NetTexture = nullptr; public: FStartScreen(int maxp) { MaxPos = maxp; } - virtual ~FStartScreen() = default; + virtual ~FStartScreen(); void Render(bool force = false); bool Progress(int); void NetProgress(int count); diff --git a/src/common/widgets/widgetresourcedata.cpp b/src/common/widgets/widgetresourcedata.cpp index 85ee3e2498..13f1519324 100644 --- a/src/common/widgets/widgetresourcedata.cpp +++ b/src/common/widgets/widgetresourcedata.cpp @@ -21,6 +21,7 @@ void InitWidgetResources(const char* filename) void CloseWidgetResources() { if (WidgetResources) delete WidgetResources; + WidgetResources = nullptr; } static std::vector LoadFile(const char* name) diff --git a/src/d_main.cpp b/src/d_main.cpp index fb25fa00fb..c00f2231c5 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -161,6 +161,7 @@ bool M_SetSpecialMenu(FName& menu, int param); // game specific checks const FIWADInfo *D_FindIWAD(TArray &wadfiles, const char *iwad, const char *basewad); void InitWidgetResources(const char* basewad); +void CloseWidgetResources(); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -3844,6 +3845,7 @@ int GameMain() M_SaveDefaultsFinal(); DeleteStartupScreen(); C_UninitCVars(); // must come last so that nothing will access the CVARs anymore after deletion. + CloseWidgetResources(); delete Args; Args = nullptr; return ret;