Fix wxWindow::IsDescendant() to work with argument equal to this window.

Passing the window itself as IsDescendant() argument for a top level window
resulted in a NULL pointer dereference. Fix this and also simplify the
function code by not using the parent window before checking it's !NULL.

Closes #14387.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71702 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-06-08 18:44:18 +00:00
parent 9bd5c5fcda
commit fd20ceff24

View File

@@ -1268,15 +1268,14 @@ bool wxWindowBase::IsDescendant(wxWindowBase* win) const
// Iterate until we find this window in the parent chain or exhaust it. // Iterate until we find this window in the parent chain or exhaust it.
while ( win ) while ( win )
{ {
wxWindow* const parent = win->GetParent(); if ( win == this )
if ( parent == this )
return true; return true;
// Stop iterating on reaching the top level window boundary. // Stop iterating on reaching the top level window boundary.
if ( parent->IsTopLevel() ) if ( win->IsTopLevel() )
break; break;
win = parent; win = win->GetParent();
} }
return false; return false;