From b0c688d810f5d9edaa9372a96423ca08a7e333b9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 31 Jul 2015 16:40:09 +0200 Subject: [PATCH] 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 efce9b23067c5110daad6466c2c5283d5dfb11c1 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. (cherry picked from commit 0e5f3612dfd0be4e7d52ea43ac16038b812a5d04) --- src/aui/auibar.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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