Apply patch [ 1554746 ] wxXmlNode::InsertChild fix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -213,9 +213,12 @@ Returns \true if this node has a property named {\it propName}.
|
||||
|
||||
\membersection{wxXmlNode::InsertChild}\label{wxxmlnodeinsertchild}
|
||||
|
||||
\func{void}{InsertChild}{\param{wxXmlNode* }{child}, \param{wxXmlNode* }{before\_node}}
|
||||
\func{bool}{InsertChild}{\param{wxXmlNode* }{child}, \param{wxXmlNode* }{before\_node}}
|
||||
|
||||
Inserts the {\it child} node after {\it before\_node} in the children list.
|
||||
If {\it before\_node} is \NULL, then {\it child} is prepended to the list of children and
|
||||
becomes the first child of this node.
|
||||
Returns \true if {\it before\_node} has been found and the {\it child} node has been inserted.
|
||||
|
||||
\membersection{wxXmlNode::RemoveChild}\label{wxxmlnoderemovechild}
|
||||
|
||||
|
@@ -115,7 +115,7 @@ public:
|
||||
wxXmlNode(wxXmlNodeType type, const wxString& name,
|
||||
const wxString& content = wxEmptyString);
|
||||
virtual void AddChild(wxXmlNode *child);
|
||||
virtual void InsertChild(wxXmlNode *child, wxXmlNode *before_node);
|
||||
virtual bool InsertChild(wxXmlNode *child, wxXmlNode *before_node);
|
||||
virtual bool RemoveChild(wxXmlNode *child);
|
||||
virtual void AddProperty(const wxString& name, const wxString& value);
|
||||
virtual bool DeleteProperty(const wxString& name);
|
||||
|
@@ -178,21 +178,40 @@ void wxXmlNode::AddChild(wxXmlNode *child)
|
||||
child->m_parent = this;
|
||||
}
|
||||
|
||||
void wxXmlNode::InsertChild(wxXmlNode *child, wxXmlNode *before_node)
|
||||
bool wxXmlNode::InsertChild(wxXmlNode *child, wxXmlNode *before_node)
|
||||
{
|
||||
wxASSERT_MSG(before_node->GetParent() == this, wxT("wxXmlNode::InsertChild - the node has incorrect parent"));
|
||||
wxCHECK_MSG(before_node == NULL || before_node->GetParent() == this, false,
|
||||
wxT("wxXmlNode::InsertChild - the node has incorrect parent"));
|
||||
wxCHECK_MSG(child, false, wxT("Cannot insert a NULL pointer!"));
|
||||
|
||||
if (m_children == before_node)
|
||||
m_children = child;
|
||||
else if (m_children == NULL)
|
||||
{
|
||||
if (before_node != NULL)
|
||||
return false; // we have no children so we don't need to search
|
||||
m_children = child;
|
||||
}
|
||||
else if (before_node == NULL)
|
||||
{
|
||||
// prepend child
|
||||
child->m_parent = this;
|
||||
child->m_next = m_children;
|
||||
m_children = child;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxXmlNode *ch = m_children;
|
||||
while (ch->m_next != before_node) ch = ch->m_next;
|
||||
while (ch && ch->m_next != before_node) ch = ch->m_next;
|
||||
if (!ch)
|
||||
return false; // before_node not found
|
||||
ch->m_next = child;
|
||||
}
|
||||
|
||||
child->m_parent = this;
|
||||
child->m_next = before_node;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxXmlNode::RemoveChild(wxXmlNode *child)
|
||||
|
Reference in New Issue
Block a user