Associate the window with the sizer in wxSizer::Replace()
If wxSizerItem passed to Replace() contains a window, the window must be associated with the sizer to ensure that it is uncoupled from it when it is destroyed. Add a simple test which resulted in a use-after-free before but passes now.
This commit is contained in:
@@ -883,6 +883,9 @@ bool wxSizer::Replace( size_t old, wxSizerItem *newitem )
|
||||
|
||||
delete item;
|
||||
|
||||
if (wxWindow* const w = newitem->GetWindow())
|
||||
w->SetContainingSizer(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user