Fix possible use of dangling window pointer in wxSizer::Insert()

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.
This commit is contained in:
Ilya Sinitsyn
2020-10-12 22:37:17 +07:00
committed by Vadim Zeitlin
parent 035fc5eb37
commit 18d56818f5
2 changed files with 36 additions and 2 deletions

View File

@@ -321,6 +321,10 @@ public:
// Enable deleting the SizerItem without destroying the contained sizer.
void DetachSizer() { m_sizer = NULL; }
// Enable deleting the SizerItem without resetting the sizer in the
// contained window.
void DetachWindow() { m_window = NULL; m_kind = Item_None; }
virtual wxSize GetSize() const;
virtual wxSize CalcMin();
virtual void SetDimension( const wxPoint& pos, const wxSize& size );