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.
This commit is contained in:
Vadim Zeitlin 2021-10-29 16:33:10 +01:00
parent 34f430a016
commit 9cc0c9a082

View File

@ -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);
}
}
}