]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/containr.cpp
Fix memory leak by letting the base class version handle the
[wxWidgets.git] / src / common / containr.cpp
index dfb7a123d86a1272de12365436e8c4cdc2d0a4d9..6df39ca62c9e2ab220a33ccf34a46a02cc0a7422 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     06.08.01
 // RCS-ID:      $Id$
 // Copyright:   (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// License:     wxWindows licence
+// License:     wxWidgets licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -51,6 +51,7 @@ wxControlContainer::wxControlContainer(wxWindow *winParent)
     m_winLastFocused =
     m_winTmpDefault =
     m_winDefault = NULL;
+    m_inSetFocus = false;
 }
 
 bool wxControlContainer::AcceptsFocus() const
@@ -293,6 +294,9 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
             // and instead give it to the first/last child depending from which
             // direction we're coming
             event.SetEventObject(m_winParent);
+            // disable propagation for this call as otherwise the event might
+            // bounce back to us.
+            wxPropagationDisabler disableProp(event);
             if ( !child->GetEventHandler()->ProcessEvent(event) )
             {
                 // set it first in case SetFocusFromKbd() results in focus
@@ -338,6 +342,11 @@ bool wxControlContainer::DoSetFocus()
     wxLogTrace(_T("focus"), _T("SetFocus on wxPanel 0x%08lx."),
                (unsigned long)m_winParent->GetHandle());
 
+    if (m_inSetFocus)
+        return true;
+
+    m_inSetFocus = true;
+    
     // when the panel gets the focus we move the focus to either the last
     // window that had the focus or the first one that can get it unless the
     // focus had been already set to some other child
@@ -361,7 +370,11 @@ bool wxControlContainer::DoSetFocus()
         win = win->GetParent();
     }
 
-    return SetFocusToChild();
+    bool ret = SetFocusToChild();
+
+    m_inSetFocus = false;
+
+    return ret;
 }
 
 void wxControlContainer::HandleOnFocus(wxFocusEvent& event)