X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/edc0a395c60f72a065d451778d64969739bf9534..54a6176249a54ac8d6467e9cf60da1ab6ba518eb:/src/common/containr.cpp

diff --git a/src/common/containr.cpp b/src/common/containr.cpp
index 55b6109a9b..700d9eb782 100644
--- a/src/common/containr.cpp
+++ b/src/common/containr.cpp
@@ -28,18 +28,12 @@
     #include "wx/log.h"
     #include "wx/event.h"
     #include "wx/window.h"
+    #include "wx/scrolbar.h"
+    #include "wx/radiobut.h"
 #endif //WX_PRECOMP
 
 #include "wx/containr.h"
 
-#ifdef __WXMAC__
-    #include "wx/scrolbar.h"
-#endif
-
-#ifdef __WXMSW__
-    #include "wx/radiobut.h"
-#endif
-
 // trace mask for focus messages
 #define TRACE_FOCUS _T("focus")
 
@@ -369,12 +363,18 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
     for ( ;; )
     {
         // don't go into infinite loop
-        if ( start_node && node == start_node )
+        if ( start_node && node && node == start_node )
             break;
 
         // Have we come to the last or first item on the panel?
         if ( !node )
         {
+            if ( !start_node )
+            {
+                // exit now as otherwise we'd loop forever
+                break;
+            }
+
             if ( !goingDown )
             {
                 // Check if our (maybe grand) parent is another panel: if this
@@ -640,4 +640,3 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
 
     return false;
 }
-