From fd20ceff24ca5f002d6424856e9d19f6d9178fb5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 8 Jun 2012 18:44:18 +0000 Subject: [PATCH] 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 --- src/common/wincmn.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index d7d6453103..2921c1f04b 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1268,15 +1268,14 @@ bool wxWindowBase::IsDescendant(wxWindowBase* win) const // Iterate until we find this window in the parent chain or exhaust it. while ( win ) { - wxWindow* const parent = win->GetParent(); - if ( parent == this ) + if ( win == this ) return true; // Stop iterating on reaching the top level window boundary. - if ( parent->IsTopLevel() ) + if ( win->IsTopLevel() ) break; - win = parent; + win = win->GetParent(); } return false; -- 2.45.2