Add the sizer item to the sizers items list only after calling of wxWindowBase::SetContainingSizer() because it can throw (if it asserts and the assert handler throws an exception, as happens in our own unit tests) and then the sizer item would be kept in the sizers items list but m_containingSizer wouldn't be set for the window.