⛏️ index : haiku.git

author Augustin Cavalier <waddlesplash@gmail.com> 2018-09-11 21:03:19.0 -04:00:00
committer waddlesplash <waddlesplash@gmail.com> 2018-09-12 1:15:39.0 +00:00:00
commit
e46d17d066f90d00a3929bc48fedb11e15f0323b [patch]
tree
269e33423ec577ad5ed5de6e0f83fdb7554c20a8
parent
0f3c9d48cc830d8d152a5adf4d09015002d70628
download
e46d17d066f90d00a3929bc48fedb11e15f0323b.tar.gz

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(-)

diff --git a/docs/user/interface/MenuItem.dox b/docs/user/interface/MenuItem.dox
index 147a506..cb2510f 100644
--- a/docs/user/interface/MenuItem.dox
+++ b/docs/user/interface/MenuItem.dox
@@ -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
*/
diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp
index c28ce3f..2d49398 100644
--- a/src/kits/interface/MenuItem.cpp
+++ b/src/kits/interface/MenuItem.cpp
@@ -181,6 +181,9 @@

BMenuItem::~BMenuItem()
{
	if (fSuper != NULL)
		fSuper->RemoveItem(this);

	free(fLabel);
	delete fSubmenu;
}