From ef3ea7e50cb6f0706651c24047f96a25edb9b521 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 27 Aug 2013 22:49:48 +0000 Subject: [PATCH] Don't recurse into top level children in wxWindow::FindWindow(). Finding a button in a child dialog when looking for it in the current window is totally unexpected and can result in subtle bugs, see #15442. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74721 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/wincmn.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index ebee014cd9..ad4887093b 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1840,6 +1840,12 @@ wxWindow *wxWindowBase::FindWindow(long id) const for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) { wxWindowBase *child = node->GetData(); + + // As usual, don't recurse into child dialogs, finding a button in a + // child dialog when looking in this window would be unexpected. + if ( child->IsTopLevel() ) + continue; + res = child->FindWindow( id ); } @@ -1856,6 +1862,11 @@ wxWindow *wxWindowBase::FindWindow(const wxString& name) const for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) { wxWindow *child = node->GetData(); + + // As in FindWindow() overload above, never recurse into child dialogs. + if ( child->IsTopLevel() ) + continue; + res = child->FindWindow(name); } -- 2.47.2