Fix assert when adding controls to wxAuiToolBar.

The code was always wrong as it added the control to a new sizer when it was
still element of an old one, but this went unnoticed until the changes of
efce9b2306 which now trigger an assert.

Fix this by deleting the old sizer, and thus breaking the association between
it and the controls inside it, before adding the controls to the new one.

Closes #17080.
This commit is contained in:
Vadim Zeitlin
2015-07-31 16:40:09 +02:00
parent 301f86ad85
commit 0e5f3612df

View File

@@ -1860,6 +1860,11 @@ bool wxAuiToolBar::Realize()
bool wxAuiToolBar::RealizeHelper(wxClientDC& dc, bool horizontal)
{
// Remove old sizer before adding any controls in this tool bar, which are
// elements of this sizer, to the new sizer below.
delete m_sizer;
m_sizer = NULL;
// create the new sizer to add toolbar elements to
wxBoxSizer* sizer = new wxBoxSizer(horizontal ? wxHORIZONTAL : wxVERTICAL);
@@ -2051,7 +2056,6 @@ bool wxAuiToolBar::RealizeHelper(wxClientDC& dc, bool horizontal)
outside_sizer->Add(m_bottomPadding, 1);
}
delete m_sizer; // remove old sizer
m_sizer = outside_sizer;
// calculate the rock-bottom minimum size