From 0ba45054d0e975bd19b2bebdc810189a2302137e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 3 Nov 2020 14:34:25 +0800 Subject: [PATCH] Fix memory release --- nel/include/nel/georges/form.h | 5 +++++ nel/include/nel/georges/form_elm.h | 8 ++++++++ nel/src/georges/form.cpp | 3 +++ nel/src/georges/form_elm.cpp | 10 ++++++---- nel/src/georges/form_loader.cpp | 2 +- nel/src/sound/audio_mixer_user.cpp | 1 + 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/nel/include/nel/georges/form.h b/nel/include/nel/georges/form.h index 9b21c4c49..732a45840 100644 --- a/nel/include/nel/georges/form.h +++ b/nel/include/nel/georges/form.h @@ -22,6 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/georges/u_form.h" +#include "form_dfn.h" #include "form_elm.h" #include "header.h" @@ -124,6 +125,10 @@ private: // The form filename std::string _Filename; + + // The dfn + NLMISC::CSmartPtr _Dfn; + }; } // NLGEORGES diff --git a/nel/include/nel/georges/form_elm.h b/nel/include/nel/georges/form_elm.h index 6795ad328..f94d9842c 100644 --- a/nel/include/nel/georges/form_elm.h +++ b/nel/include/nel/georges/form_elm.h @@ -282,6 +282,10 @@ public: { Element = NULL; } + ~CFormElmStructElm() + { + nlassert(!Element); + } std::string Name; CFormElm* Element; @@ -400,6 +404,10 @@ public: { Element = NULL; } + ~CElement () + { + nlassert(!Element); + } std::string Name; CFormElm* Element; diff --git a/nel/src/georges/form.cpp b/nel/src/georges/form.cpp index 2f9ecf9b1..63e4ee2ed 100644 --- a/nel/src/georges/form.cpp +++ b/nel/src/georges/form.cpp @@ -191,6 +191,9 @@ void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const std // Reset form clean (); + // Save the dfn + _Dfn = dfn; + // Check node name if ( ((const char*)node->name == NULL) || (strcmp ((const char*)node->name, "FORM") != 0) ) { diff --git a/nel/src/georges/form_elm.cpp b/nel/src/georges/form_elm.cpp index af87a2e0a..358b45f65 100644 --- a/nel/src/georges/form_elm.cpp +++ b/nel/src/georges/form_elm.cpp @@ -1707,6 +1707,7 @@ CFormElmStruct::CFormElmStruct (CForm *form, CFormElm *parentNode, const CFormDf CFormElmStruct::~CFormElmStruct () { // Job done in clean() + clean(); } // *************************************************************************** @@ -1717,10 +1718,10 @@ void CFormElmStruct::clean () uint elm; for (elm =0; elm dfn = loadFormDfn (name, false); if (dfn) { // Open the file diff --git a/nel/src/sound/audio_mixer_user.cpp b/nel/src/sound/audio_mixer_user.cpp index 5d037750b..3f6a5dcbe 100644 --- a/nel/src/sound/audio_mixer_user.cpp +++ b/nel/src/sound/audio_mixer_user.cpp @@ -695,6 +695,7 @@ void CAudioMixerUser::initDevice(const std::string &deviceName, const CInitInfo setBackgroundFlags(flags); } + form = NULL; NLGEORGES::UFormLoader::releaseLoader(formLoader); } }