Fix memory release

develop
kaetemi 4 years ago
parent f50b59702e
commit 0ba45054d0

@ -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<CFormDfn> _Dfn;
};
} // NLGEORGES

@ -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;

@ -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) )
{

@ -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<Elements.size(); elm++)
{
if (Elements[elm].Element)
delete Elements[elm].Element;
Elements[elm].Element = NULL;
}
Elements.clear();
}
// ***************************************************************************
@ -2270,6 +2271,7 @@ CFormElmArray::CFormElmArray (CForm *form, const CFormDfn *formDfn, const CType
CFormElmArray::~CFormElmArray ()
{
// Job done in clean()
clean();
}
// ***************************************************************************
@ -2280,8 +2282,8 @@ void CFormElmArray::clean ()
uint elm;
for (elm =0; elm<Elements.size(); elm++)
{
if (Elements[elm].Element)
delete Elements[elm].Element;
Elements[elm].Element = NULL;
}
Elements.clear ();
}

@ -241,7 +241,7 @@ UForm *CFormLoader::loadForm (const std::string &filename)
name += ".dfn";
// Load the dfn
CFormDfn *dfn = loadFormDfn (name, false);
CSmartPtr<CFormDfn> dfn = loadFormDfn (name, false);
if (dfn)
{
// Open the file

@ -695,6 +695,7 @@ void CAudioMixerUser::initDevice(const std::string &deviceName, const CInitInfo
setBackgroundFlags(flags);
}
form = NULL;
NLGEORGES::UFormLoader::releaseLoader(formLoader);
}
}

Loading…
Cancel
Save