From e700a029647dd28a0d9104a9bb68dcac30b8e624 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 16 Jan 2020 23:29:00 +0100 Subject: [PATCH] Use correct toolbar tool index when determining best size Closes #18652. Closes https://github.com/wxWidgets/wxWidgets/pull/1708 --- src/msw/toolbar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index e49accac0b..dd354dc95d 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -597,7 +597,8 @@ wxSize wxToolBar::DoGetBestSize() const wxToolBarToolsList::compatibility_iterator node; int toolIndex = 0; - for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) + for ( node = m_tools.GetFirst(); node; node = node->GetNext(), + toolIndex++ ) { wxToolBarTool * const tool = static_cast(node->GetData()); @@ -621,7 +622,7 @@ wxSize wxToolBar::DoGetBestSize() const // items do have this size, this is not true for the separators and it // is both more robust and simpler to just always use TB_GETITEMRECT // rather than handling the separators specially. - const RECT rcItem = wxGetTBItemRect(GetHwnd(), toolIndex++); + const RECT rcItem = wxGetTBItemRect(GetHwnd(), toolIndex); if ( IsVertical() ) {