From 24a7a1980f309763c349541daffa46f1a5fd16b2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 6 Aug 2001 12:12:32 +0000 Subject: [PATCH] fixed infinite recursion in SetFocus() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/containr.h | 8 +++++--- src/common/containr.cpp | 7 ++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/wx/containr.h b/include/wx/containr.h index 456c8354d3..11a3dddf98 100644 --- a/include/wx/containr.h +++ b/include/wx/containr.h @@ -52,8 +52,9 @@ public: void HandleOnFocus(wxFocusEvent& event); void HandleOnWindowDestroy(wxWindowBase *child); - // should be called from SetFocus() - void DoSetFocus(); + // should be called from SetFocus(), returns FALSE if we did nothing with + // the focus and the default processing should take place + bool DoSetFocus(); protected: // set the focus to the child which had it the last time @@ -119,7 +120,8 @@ void classname::RemoveChild(wxWindowBase *child) \ \ void classname::SetFocus() \ { \ - container->DoSetFocus(); \ + if ( !container->DoSetFocus() ) \ + wxWindow::SetFocus(); \ } \ \ void classname::OnChildFocus(wxChildFocusEvent& event) \ diff --git a/src/common/containr.cpp b/src/common/containr.cpp index 2cac0008ac..04a7794bfe 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -241,7 +241,7 @@ void wxControlContainer::HandleOnWindowDestroy(wxWindowBase *child) // focus handling // ---------------------------------------------------------------------------- -void wxControlContainer::DoSetFocus() +bool wxControlContainer::DoSetFocus() { wxLogTrace(_T("focus"), _T("SetFocus on wxPanel 0x%08x."), m_winParent->GetHandle()); @@ -273,10 +273,7 @@ void wxControlContainer::DoSetFocus() // // RR: Removed for now. Let's see what happens.. - if ( !SetFocusToChild() ) - { - m_winParent->SetFocus(); - } + return SetFocusToChild(); } void wxControlContainer::HandleOnFocus(wxFocusEvent& event) -- 2.45.2