Yet another fix after wxMenu::Remove() refactoring.
wxMenu::Remove() was still broken in wxMSW after r75250, even with the fix in r75290, as wxMSW code relied on the item still being present in wxMenu::m_items. Delay removing it from there until after DoRemove() call to fix this. See #3424. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75297 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -428,11 +428,16 @@ wxMenuItem *wxMenuBase::Remove(wxMenuItem *item)
|
|||||||
// if we get here, the item is valid or one of Remove() functions is broken
|
// if we get here, the item is valid or one of Remove() functions is broken
|
||||||
wxCHECK_MSG( node, NULL, wxT("removing item not in the menu?") );
|
wxCHECK_MSG( node, NULL, wxT("removing item not in the menu?") );
|
||||||
|
|
||||||
|
// call DoRemove() before removing the item from the list of items as the
|
||||||
|
// existing code in port-specific implementation may rely on the item still
|
||||||
|
// being there (this is the case for at least wxMSW)
|
||||||
|
wxMenuItem* const item2 = DoRemove(item);
|
||||||
|
|
||||||
// we detach the item, but we do delete the list node (i.e. don't call
|
// we detach the item, but we do delete the list node (i.e. don't call
|
||||||
// DetachNode() here!)
|
// DetachNode() here!)
|
||||||
m_items.Erase(node);
|
m_items.Erase(node);
|
||||||
|
|
||||||
return DoRemove(item);
|
return item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item)
|
wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item)
|
||||||
|
@@ -793,9 +793,6 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
|
|||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoRemove() (unlike Remove) can only be called for an existing item!
|
|
||||||
wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") );
|
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
// remove the corresponding accel from the accel table
|
// remove the corresponding accel from the accel table
|
||||||
int n = FindAccel(item->GetId());
|
int n = FindAccel(item->GetId());
|
||||||
|
Reference in New Issue
Block a user