BMenuItem: Remove ourselves from the super menu on destruct.
This fixes the (intermittently) crashing test added in the previous commit,
and should also fix #12024 and #14348.
Note that this is a slight behavioral departure from BeOS, though since
BeOS crashed when this was done previously, it shouldn't cause any
other problems.
Change-Id: I7ac271258afaf1bcf649e0e44ab31184b6dc92f1
Reviewed-on: https://review.haiku-os.org/542
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Diff
docs/user/interface/MenuItem.dox | 4 ++++
src/kits/interface/MenuItem.cpp | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)
@@ -115,7 +115,9 @@
\fn BMenuItem::~BMenuItem()
\brief Destructor.
Also frees the memory used by the label or submenu.
If this item is attached to a menu, it will be removed from it.
Also destroys the label and submenu.
\since BeOS R3
*/
@@ -181,6 +181,9 @@
BMenuItem::~BMenuItem()
{
if (fSuper != NULL)
fSuper->RemoveItem(this);
free(fLabel);
delete fSubmenu;
}