X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/029b47ad2c148de62a88e50589314a7a327f8b68..f0244295e3a35a37473e9ba83d6ceea0d17259da:/include/wx/window.h diff --git a/include/wx/window.h b/include/wx/window.h index 2270ca10c3..596dadc0a4 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -831,7 +831,17 @@ public: wxSizer *GetSizer() const { return m_windowSizer; } // Track if this window is a member of a sizer - void SetContainingSizer(wxSizer* sizer) { m_containingSizer = sizer; } + void SetContainingSizer(wxSizer* sizer) + { + // adding a window to a sizer twice is going to result in fatal and + // hard to debug problems later because when deleting the second + // associated wxSizerItem we're going to dereference a dangling + // pointer; so try to detect this as early as possible + wxASSERT_MSG( !sizer || m_containingSizer != sizer, + _T("Adding a window to the same sizer twice?") ); + + m_containingSizer = sizer; + } wxSizer *GetContainingSizer() const { return m_containingSizer; } // accessibility