From 6b6fee8685dc7f4d0a68d99d56686ec82e2b4bca Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Mar 2019 19:13:45 +0100 Subject: [PATCH] Avoid TB_DELETEBUTTON errors when recreating wxMSW wxToolBar Reset the number of buttons to skip deleting the old buttons in wxToolBar::Recreate() as these buttons don't exist any more (having been created in the old control) and trying to delete them just results in debug error messages from TB_DELETEBUTTON. --- src/msw/toolbar.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index b21a99fd1a..3a397be743 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -519,6 +519,11 @@ void wxToolBar::Recreate() wxDELETE(m_disabledImgList); + // Also skip deleting the existing buttons in Realize(): they don't exist + // any more, so doing this is unnecessary and just results in errors from + // TB_DELETEBUTTON. + m_nButtons = 0; + Realize(); }