From 9cc0c9a082e0c3b2a4c14e3c6811de0e3a1a3799 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Oct 2021 16:33:10 +0100 Subject: [PATCH] Only check sizer elements if there is valid containing window This is another correction to the changes of 62c3d921b2 (Check that all windows in a sizer use associated window as parent, 2021-10-20): we need to restrict the part of this check in wxSizer::SetContainingWindow() to the case when this function argument is non-null, otherwise the check would always fail. Notice that it is perfectly valid to call SetContainingWindow(NULL) and wxWrapSizer does it for every re-layout, for example. This commit is best viewed ignoring whitespace-only changes. See #19308. --- src/common/sizer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index d3ef62151a..03c9d4bd58 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -879,8 +879,13 @@ void wxSizer::SetContainingWindow(wxWindow *win) sizer->SetContainingWindow(win); } - if ( wxWindow* const w = item->GetWindow() ) - ASSERT_WINDOW_PARENT_IS(w, m_containingWindow); + // If we have a valid containing window, check that all windows managed + // by this sizer were correctly created using it as parent. + if ( m_containingWindow ) + { + if ( wxWindow* const w = item->GetWindow() ) + ASSERT_WINDOW_PARENT_IS(w, m_containingWindow); + } } }