From d0e2a8c85c34f8b463c316a21d90dde318f75637 Mon Sep 17 00:00:00 2001 From: srn Date: Fri, 2 Nov 2007 08:54:00 +0000 Subject: [PATCH] Fixed bug in method FindChild --- src/DF/DF_Label.cxx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/DF/DF_Label.cxx b/src/DF/DF_Label.cxx index 8bfd113ad..453630a3f 100644 --- a/src/DF/DF_Label.cxx +++ b/src/DF/DF_Label.cxx @@ -296,18 +296,15 @@ DF_Label DF_Label::FindChild(int theTag, bool isCreate) DF_LabelNode *aLabel = NULL, *aPrevious = NULL, *aNext = NULL; if(!_node->_firstChild && !isCreate) return DF_Label(); - if(_node->_firstChild && _node->_firstChild->_tag == theTag) - return DF_Label(_node->_firstChild); - + if(_node->_firstChild && _node->_firstChild->_tag == theTag) + return DF_Label(_node->_firstChild); + if(_node->_lastChild) { - if( _node->_lastChild->_tag == theTag) { - return DF_Label(_node->_lastChild); - } - else if( _node->_lastChild->_tag < theTag) { //Incremental addition of children - aPrevious = _node->_lastChild; - } + if(_node->_lastChild->_tag == theTag) return DF_Label(_node->_lastChild); + if(_node->_lastChild->_tag < theTag) aPrevious = _node->_lastChild; } - else { + + if(!aPrevious) { aLabel = _node->_firstChild; while(aLabel) { if(aLabel->_tag == theTag) return DF_Label(aLabel); @@ -339,9 +336,7 @@ DF_Label DF_Label::FindChild(int theTag, bool isCreate) } if(!_node->_firstChild || (aNext && aNext == _node->_firstChild) ) _node->_firstChild = aChild; - if(!aNext) { - _node->_lastChild = aChild; - } + if(!_node->_lastChild || !aNext) _node->_lastChild = aChild; return aChild; } -- 2.39.2