Sometimes my program crashes when invoking TiXmlNode::LinkEndChild(), I don't know why the crash occurs, below is the detail about this kind of crash:
<<source code>>
TiXmlElement * tmpElement = new TiXmlElement("Maybe some certain identifier");
//......
//some code, for example, tmpElement.SetAttribute(ID, value);
//......
TiXmlText * cdata = new TiXmlText(sValue); //the type of sValue is 'std::string'
cdata->SetCDATA(true);
aElement->LinkEndChild(cdata);
if ( lastChild )
lastChild->next = node; //******the breakpoint or crash-point is at this line******//
else
firstChild = node;
lastChild = node;
return node;
}
As implied by the source code above, the lastChild of tmpElement should be NULL/0 as my program doesn't link any node(child) before the invocation of TiXmlNode::LinkEndChild(), but the fact is that the lastChild of tmpElement has been modified somewhere and it doesn't equal to NULL/0, I have spent more than three days looking for the reason, but it's just a waste of time, so do you know something about it? or do you have encoutered the same problem? any feedbacks are appreciated, thanks in advance.
with best regards,
James
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi James
I don't know if you found your problem or not, but do you have a small, all-in-one-main() compilable version that reproduces the problem?
Ellers
PS
It's probably not relevant but you use a variable called tmpElement then reference aElement?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Everybody,
Sometimes my program crashes when invoking TiXmlNode::LinkEndChild(), I don't know why the crash occurs, below is the detail about this kind of crash:
<<source code>>
TiXmlElement * tmpElement = new TiXmlElement("Maybe some certain identifier");
//......
//some code, for example, tmpElement.SetAttribute(ID, value);
//......
TiXmlText * cdata = new TiXmlText(sValue); //the type of sValue is 'std::string'
cdata->SetCDATA(true);
aElement->LinkEndChild(cdata);
<<crash inside TiXmlNode::LinkEndChild()>>
TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
{
assert( node->parent == 0 || node->parent == this );
assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
node->parent = this;
node->prev = lastChild;zz
node->next = 0;
if ( lastChild )
lastChild->next = node; //******the breakpoint or crash-point is at this line******//
else
firstChild = node;
lastChild = node;
return node;
}
As implied by the source code above, the lastChild of tmpElement should be NULL/0 as my program doesn't link any node(child) before the invocation of TiXmlNode::LinkEndChild(), but the fact is that the lastChild of tmpElement has been modified somewhere and it doesn't equal to NULL/0, I have spent more than three days looking for the reason, but it's just a waste of time, so do you know something about it? or do you have encoutered the same problem? any feedbacks are appreciated, thanks in advance.
with best regards,
James
Sorry, I forgot to tell you the details about my development environment.
My operating system is windows xp sp2, and my IDE is MS VS2005 professional.
Hi James
I don't know if you found your problem or not, but do you have a small, all-in-one-main() compilable version that reproduces the problem?
Ellers
PS
It's probably not relevant but you use a variable called tmpElement then reference aElement?