From 9a48c2ba3dc319c2cea520ca9ac54d2081362a39 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 6 Apr 1999 08:50:10 +0000 Subject: [PATCH] bug in FindItemForId() fixed (?) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2048 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/menu.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 14d738290c..097765df9d 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -469,7 +469,6 @@ void wxMenu::ProcessCommand(wxCommandEvent & event) // Finds the item id matching the given string, -1 if not found. int wxMenu::FindItem (const wxString& itemString) const { - // FIXME fixed size buffer wxString itemLabel = wxStripMenuCodes(itemString); for ( wxNode *node = m_menuItems.First(); node; node = node->Next() ) { @@ -497,7 +496,7 @@ wxMenuItem *wxMenu::FindItemForId(int itemId, wxMenu ** itemMenu) const *itemMenu = NULL; wxMenuItem *item = NULL; - for ( wxNode *node = m_menuItems.First(); node; node = node->Next() ) + for ( wxNode *node = m_menuItems.First(); node && !item; node = node->Next() ) { item = (wxMenuItem *)node->Data(); @@ -505,13 +504,15 @@ wxMenuItem *wxMenu::FindItemForId(int itemId, wxMenu ** itemMenu) const { if (itemMenu) *itemMenu = (wxMenu *)this; - break; } else if ( item->IsSubMenu() ) { item = item->GetSubMenu()->FindItemForId(itemId, itemMenu); - if ( item ) - break; + } + else + { + // don't exit the loop + item = NULL; } } -- 2.45.2