From ddce6780f681284590922eac40ec82970ce6987d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 16 Dec 2014 20:16:23 +0000 Subject: [PATCH] Fix inserting tools removed from wxToolBar back into it in wxMSW. Make sure to reset the "to be deleted" flag we set on the tool when removing it from the toolbar to avoid layout problems if the tool is added back later. Closes #16735. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78279 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/toolbar.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 6e1fb5e751..b136869a8b 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -228,7 +228,7 @@ public: } } - void ToBeDeleted() { m_toBeDeleted = true; } + void ToBeDeleted(bool toBeDeleted = true) { m_toBeDeleted = toBeDeleted; } bool IsToBeDeleted() const { return m_toBeDeleted; } private: @@ -570,8 +570,13 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const // ---------------------------------------------------------------------------- bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), - wxToolBarToolBase * WXUNUSED(tool)) + wxToolBarToolBase *tool) { + // We might be inserting back a tool previously removed from the toolbar, + // make sure to reset its "to be deleted" flag to ensure that we do take it + // into account during our layout even in this case. + static_cast(tool)->ToBeDeleted(false); + // nothing special to do here - we really create the toolbar buttons in // Realize() later InvalidateBestSize();