Tracker: Cleanup menu items better in DeleteSubmenu()

Change-Id: Ie0679393c208e8dcaf23f975ba3d9bd2d12bad12
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8228
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
This commit is contained in:
John Scipione 2024-09-04 13:42:09 -04:00 committed by waddlesplash
parent 84bdf57a71
commit 77fafacae3

View File

@ -1433,17 +1433,12 @@ DeleteSubmenu(BMenuItem* submenuItem)
if (submenuItem == NULL)
return;
BMenu* menu = submenuItem->Submenu();
if (menu == NULL)
BMenu* submenu = submenuItem->Submenu();
if (submenu == NULL)
return;
for (;;) {
BMenuItem* item = menu->RemoveItem((int32)0);
if (item == NULL)
return;
delete item;
}
// delete all submenu items
submenu->RemoveItems(0, submenu->CountItems(), true);
}