[GB.XML]
* BUG: Solved a few memory leaks. git-svn-id: svn://localhost/gambas/trunk@4872 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
7a126b76e3
commit
c4375aa197
5 changed files with 48 additions and 5 deletions
|
@ -31,6 +31,7 @@
|
|||
BEGIN_METHOD(CDocument_new, GB_STRING fileName)
|
||||
|
||||
if(Node::NoInstanciate) return;
|
||||
if(GB.Is(_object, GB.FindClass("HtmlDocument"))) return;//Called as inherited HtmlDocument constructor
|
||||
|
||||
if(!MISSING(fileName))
|
||||
{
|
||||
|
@ -47,7 +48,7 @@ END_METHOD
|
|||
|
||||
BEGIN_METHOD_VOID(CDocument_free)
|
||||
|
||||
//delete THIS;
|
||||
delete THIS;
|
||||
|
||||
END_METHOD
|
||||
|
||||
|
@ -158,8 +159,9 @@ END_METHOD
|
|||
BEGIN_METHOD(CDocument_createElement, GB_STRING tagName)
|
||||
|
||||
Element *elmt = new Element(STRING(tagName), LENGTH(tagName));
|
||||
|
||||
Node::NoInstanciate = true;
|
||||
GBI::Return(elmt);
|
||||
Node::NoInstanciate = false;
|
||||
|
||||
END_METHOD
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
BEGIN_METHOD(CElement_new, GB_STRING tagName)
|
||||
|
||||
if(Node::NoInstanciate) return;
|
||||
if(GB.Component.Exist("gb.xml.html")) return;//html part override
|
||||
|
||||
if(!MISSING(tagName))
|
||||
{
|
||||
|
|
|
@ -537,7 +537,7 @@ void Element::setTagName(const char *ntagName, size_t nlenTagName)
|
|||
else
|
||||
{
|
||||
lenTagName = nlenTagName;
|
||||
tagName = (char*)malloc(sizeof(char) * lenTagName);
|
||||
tagName = (char*)realloc(tagName, sizeof(char) * lenTagName);
|
||||
memcpy(tagName, ntagName, lenTagName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,15 @@ BEGIN_METHOD_VOID(CDocument_free)
|
|||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(CDocument_createElement, GB_STRING tagName)
|
||||
|
||||
Element *elmt = new Element(STRING(tagName), LENGTH(tagName));
|
||||
Node::NoInstanciate = true;
|
||||
GBI::Return(elmt);
|
||||
Node::NoInstanciate = false;
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_PROPERTY(CDocument_Html5)
|
||||
|
||||
if(READ_PROPERTY)
|
||||
|
@ -117,34 +126,44 @@ END_PROPERTY
|
|||
|
||||
BEGIN_PROPERTY(CDocument_root)
|
||||
|
||||
Node::NoInstanciate = true;
|
||||
GBI::Return(THIS->root);
|
||||
Node::NoInstanciate = false;
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(CDocument_head)
|
||||
|
||||
Node::NoInstanciate = true;
|
||||
GBI::Return(THIS->getHead());
|
||||
Node::NoInstanciate = false;
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(CDocument_body)
|
||||
|
||||
Node::NoInstanciate = true;
|
||||
GBI::Return(THIS->getBody());
|
||||
Node::NoInstanciate = false;
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_METHOD(CDocument_getElementById, GB_STRING id; GB_INTEGER depth)
|
||||
|
||||
Node::NoInstanciate = true;
|
||||
GBI::Return(THIS->getElementById(STRING(id), LENGTH(id), VARGOPT(depth, -1)));
|
||||
Node::NoInstanciate = false;
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(CDocument_getElementsByClassName, GB_STRING className; GB_INTEGER depth)
|
||||
|
||||
Node::NoInstanciate = true;
|
||||
if(LENGTH(className) <= 0) return;
|
||||
GB_ARRAY array;
|
||||
THIS->getElementsByClassName(STRING(className), LENGTH(className), &array, VARGOPT(depth, -1));
|
||||
GB.ReturnObject(array);
|
||||
Node::NoInstanciate = false;
|
||||
|
||||
END_METHOD
|
||||
|
||||
|
@ -242,7 +261,9 @@ GB_DESC CDocumentDesc[] =
|
|||
|
||||
GB_METHOD("_new", "", CDocument_new, "[(Path)s]"),
|
||||
GB_METHOD("_free", "", CDocument_free, ""),
|
||||
|
||||
|
||||
|
||||
GB_METHOD("CreateElement", "XmlElement", CDocument_createElement, "(TagName)s"),
|
||||
GB_PROPERTY("Html5", "b", CDocument_Html5),
|
||||
//GB_METHOD("ForceSetContent", "", CDocument_forceSetContent, "(Data)s"),
|
||||
GB_PROPERTY("Title", "s", CDocument_Title),
|
||||
|
|
|
@ -26,7 +26,25 @@
|
|||
/*========== Element */
|
||||
|
||||
#undef THIS
|
||||
#undef THISNODE
|
||||
#define THIS (static_cast<CNode*>(_object)->node->toElement())
|
||||
#define THISNODE (static_cast<CNode*>(_object)->node)
|
||||
|
||||
BEGIN_METHOD(CElement_new, GB_STRING tagName)
|
||||
|
||||
if(Node::NoInstanciate) return;
|
||||
|
||||
if(!MISSING(tagName))
|
||||
{
|
||||
THISNODE = new Element(STRING(tagName), LENGTH(tagName));
|
||||
}
|
||||
else
|
||||
{
|
||||
THISNODE = new Element;
|
||||
}
|
||||
THIS->GBObject = static_cast<CNode*>(_object);
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_PROPERTY(CElement_id)
|
||||
|
||||
|
@ -91,7 +109,8 @@ END_METHOD
|
|||
GB_DESC CElementDesc[] =
|
||||
{
|
||||
GB_DECLARE("XmlElement", sizeof(CNode)),
|
||||
|
||||
|
||||
GB_METHOD("_new", "", CElement_new, "[(TagName)s]"),
|
||||
|
||||
GB_PROPERTY("Id", "s", CElement_id),
|
||||
GB_PROPERTY("ClassName", "s", CElement_className),
|
||||
|
|
Loading…
Reference in a new issue