Fix assert message when removing non-existent items from wxMenu.
The assert complained about a bug in wxMenu code itself, but actually could be triggered by simply trying to remove a non-existent item from the menu. Fix this by checking for the item existence, and also removing it from the internal menu data structure, in wxMenuBase::Remove() and only dealing with the item itself in DoRemove(). Closes #3424. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -423,21 +423,20 @@ wxMenuItem *wxMenuBase::Remove(wxMenuItem *item)
|
||||
{
|
||||
wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Remove") );
|
||||
|
||||
return DoRemove(item);
|
||||
}
|
||||
|
||||
wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item)
|
||||
{
|
||||
wxMenuItemList::compatibility_iterator node = m_items.Find(item);
|
||||
|
||||
// if we get here, the item is valid or one of Remove() functions is broken
|
||||
wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") );
|
||||
wxCHECK_MSG( node, NULL, wxT("removing item not in the menu?") );
|
||||
|
||||
// we detach the item, but we do delete the list node (i.e. don't call
|
||||
// DetachNode() here!)
|
||||
m_items.Erase(node);
|
||||
|
||||
// item isn't attached to anything any more
|
||||
return DoRemove(item);
|
||||
}
|
||||
|
||||
wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item)
|
||||
{
|
||||
item->SetMenu(NULL);
|
||||
wxMenu *submenu = item->GetSubMenu();
|
||||
if ( submenu )
|
||||
|
Reference in New Issue
Block a user