From 2e33165edfa29840b4ff9d9d2cf80796567dec9f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 10 Jul 2017 10:41:50 +0300 Subject: [PATCH] Moved freeing of data stored in HUD message objects to OnDestroy() function https://forum.zdoom.org/viewtopic.php?t=57163 --- src/g_shared/hudmessages.cpp | 3 ++- src/g_statusbar/sbar.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/g_shared/hudmessages.cpp b/src/g_shared/hudmessages.cpp index caa041d4c..722fb353d 100644 --- a/src/g_shared/hudmessages.cpp +++ b/src/g_shared/hudmessages.cpp @@ -150,7 +150,7 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h // //============================================================================ -DHUDMessage::~DHUDMessage () +void DHUDMessage::OnDestroy() { if (Lines) { @@ -164,6 +164,7 @@ DHUDMessage::~DHUDMessage () if (SourceText != NULL) { delete[] SourceText; + SourceText = nullptr; } } diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index e4ca894ac..42b164e2b 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -66,7 +66,7 @@ class DHUDMessage : public DObject public: DHUDMessage (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight, EColorRange textColor, float holdTime); - virtual ~DHUDMessage (); + virtual void OnDestroy () override; virtual void Serialize(FSerializer &arc);