From: Vadim Zeitlin Date: Tue, 21 Mar 2006 12:53:28 +0000 (+0000) Subject: fix an infinite loop in HandleOnNavigationKey() when wxUSE_STL==1 and start_node... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/edc0a395c60f72a065d451778d64969739bf9534 fix an infinite loop in HandleOnNavigationKey() when wxUSE_STL==1 and start_node is NULL git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38239 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/containr.cpp b/src/common/containr.cpp index b4b63b63af..55b6109a9b 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -302,7 +302,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) } // where are we going? - bool forward = event.GetDirection(); + const bool forward = event.GetDirection(); // the node of the children list from which we should start looking for the // next acceptable child @@ -319,11 +319,8 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) // start from first or last depending on where we're going node = forward ? children.GetFirst() : children.GetLast(); - - // we want to cycle over all nodes - start_node = wxWindowList::compatibility_iterator(); } - else + else // going up { // try to find the child which has the focus currently @@ -349,10 +346,6 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) // ok, we found the focus - now is it our child? start_node = children.Find( winFocus ); } - else - { - start_node = wxWindowList::compatibility_iterator(); - } if ( !start_node && m_winLastFocused ) { @@ -373,14 +366,18 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) } // we want to cycle over all elements passing by NULL - while ( node != start_node ) + for ( ;; ) { + // don't go into infinite loop + if ( start_node && node == start_node ) + break; + // Have we come to the last or first item on the panel? if ( !node ) { if ( !goingDown ) { - // Check if our (may be grand) parent is another panel: if this + // Check if our (maybe grand) parent is another panel: if this // is the case, they will know what to do with this navigation // key and so give them the chance to process it instead of // looping inside this panel (normally, the focus will go to