diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index 96707599fd..eaa93ed74a 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -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