From 0930541da9272f922183d910ad454cb2f9ffb39b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 1 Apr 2014 12:46:52 +0000 Subject: [PATCH] Fix recently introduced assert when using owner drawn items in wxMSW. Relax the check added in r76202, the item might not be added to its parent menu yet even if the menu is not NULL. See #13878. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76251 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/menuitem.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 5577320ea7..9c355795ae 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -768,13 +768,16 @@ void wxMenuItem::DoSetBitmap(const wxBitmap& bmp, bool bChecked) // (all other menu items have to be also set to owner-drawn mode). if ( m_parentMenu ) { - wxMenu *menu = m_parentMenu; size_t pos; - wxMenuItem *item = menu->FindChildItem(GetMSWId(), &pos); - wxCHECK_RET( item == this, wxS("Non unique menu item ID?") ); + wxMenuItem *item = m_parentMenu->FindChildItem(GetMSWId(), &pos); + if ( item ) + { + wxCHECK_RET( item == this, wxS("Non unique menu item ID?") ); - menu->Remove(this); - menu->Insert(pos, this); + m_parentMenu->Remove(this); + m_parentMenu->Insert(pos, this); + } + //else: the item hasn't been inserted into the parent menu yet } return; }