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: I90b6132ff7741b8d6cb601375a9b11fc3ffacb40
Reviewed-on: https://review.haiku-os.org/541
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Augustin Cavalier 2018-09-11 21:03:19 -04:00 committed by waddlesplash
parent 4628b6de8e
commit c3ac0a72a6
2 changed files with 6 additions and 1 deletions

View File

@ -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
*/

View File

@ -181,6 +181,9 @@ BMenuItem::Archive(BMessage* data, bool deep) const
BMenuItem::~BMenuItem()
{
if (fSuper != NULL)
fSuper->RemoveItem(this);
free(fLabel);
delete fSubmenu;
}