Menu

#1 Bug in insertAfter and insertBefore methods

open
nobody
None
5
2006-06-08
2006-06-08
No

Hi.

We discovered a bug in your MXML library. This bug is
located in insertBefore and insertAfter methods. It
regards about missing pointer link on m_prev (for
insertAfter) and m_next (for insertBefore).

Following code is a functional patch:

void Node::insertBefore( Node *node )
{
node->m_next = this;
node->m_prev = m_prev;
node->m_parent = m_parent;

// HERE IS OUR PATCH
if( m_prev )
m_prev->m_next = node ;

/* puts the node on top of hierarchy if needed */
if ( m_parent != 0 && m_parent->m_child == this )
m_parent->m_child = node;

m_prev = node;

}

void Node::insertAfter( Node *node )
{
node->m_next = m_next;
node->m_prev = this;
node->m_parent = m_parent;

// HERE IS OUR PATCH
if( m_next )
m_next->m_prev = node ;
/* puts the node on bottom of hierarchy if needed */
if ( m_parent != NULL && m_parent->m_last_child ==
this )
m_parent->m_last_child = node;

m_next = node;

}

Hope that this will fix your bug.

Regards,
Tony & Marco.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.