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
This commit is contained in:
@@ -1840,6 +1840,12 @@ wxWindow *wxWindowBase::FindWindow(long id) const
|
|||||||
for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
|
for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
wxWindowBase *child = node->GetData();
|
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 );
|
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() )
|
for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
wxWindow *child = node->GetData();
|
wxWindow *child = node->GetData();
|
||||||
|
|
||||||
|
// As in FindWindow() overload above, never recurse into child dialogs.
|
||||||
|
if ( child->IsTopLevel() )
|
||||||
|
continue;
|
||||||
|
|
||||||
res = child->FindWindow(name);
|
res = child->FindWindow(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user