Fix exception while reinserting menu item.
After removing an item from a menu that item's parent menu is set to NULL and can't be used any longer to insert the item again. Fix by remembering the parent menu before removing the item from it. Regression since r76251 (this commit is a partial revert of that commit). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76755 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -780,8 +780,11 @@ void wxMenuItem::DoSetBitmap(const wxBitmap& bmp, bool bChecked)
|
||||
{
|
||||
wxCHECK_RET( item == this, wxS("Non unique menu item ID?") );
|
||||
|
||||
m_parentMenu->Remove(this);
|
||||
m_parentMenu->Insert(pos, this);
|
||||
// Use a copied value of m_parentMenu because it is
|
||||
// nullified by Remove.
|
||||
wxMenu *menu = m_parentMenu;
|
||||
menu->Remove(this);
|
||||
menu->Insert(pos, this);
|
||||
}
|
||||
//else: the item hasn't been inserted into the parent menu yet
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user