diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp index abda494fca..60227e0c59 100644 --- a/src/apps/deskbar/BarWindow.cpp +++ b/src/apps/deskbar/BarWindow.cpp @@ -144,16 +144,11 @@ TBarWindow::MenusEnded() { BWindow::MenusEnded(); - if (!sBeMenu->LockLooper()) { + if (sBeMenu->LockLooper()) { // TODO: is this ok? - return; + sBeMenu->RemoveItems(0, sBeMenu->CountItems(), true); + sBeMenu->UnlockLooper(); } - - BMenuItem *item = NULL; - while ((item = sBeMenu->RemoveItem((int32)0)) != NULL) - delete item; - - sBeMenu->UnlockLooper(); } diff --git a/src/apps/deskbar/BeMenu.cpp b/src/apps/deskbar/BeMenu.cpp index 30c413fa27..0fefc52b5b 100644 --- a/src/apps/deskbar/BeMenu.cpp +++ b/src/apps/deskbar/BeMenu.cpp @@ -138,14 +138,7 @@ TBeMenu::DetachedFromWindow() bool TBeMenu::StartBuildingItemList() { - int32 count = CountItems()-1; - for (int32 index = count; index >= 0; index--) { - BMenuItem *item = ItemAt(index); - ASSERT(item); - - RemoveItem(index); - delete item; - } + RemoveItems(0, CountItems(), true); fAddState = kStart; return BNavMenu::StartBuildingItemList(); } @@ -555,14 +548,7 @@ TRecentsMenu::DetachedFromWindow() bool TRecentsMenu::StartBuildingItemList() { - int32 count = CountItems()-1; - for (int32 index = count; index >= 0; index--) { - BMenuItem *item = ItemAt(index); - ASSERT(item); - - RemoveItem(index); - delete item; - } + RemoveItems(0, CountItems(), true); // !! note: don't call inherited from here // the navref is not set for this menu @@ -732,9 +718,7 @@ MountMenu::MountMenu(const char *name) bool MountMenu::AddDynamicItem(add_state s) { - BMenuItem *item; - while ((item = RemoveItem(0L)) != NULL) - delete item; + RemoveItems(0, CountItems(), true); // Send message to tracker to get items. BMessage request('gmtv'); diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 661b1e18e5..111309b3f1 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -191,9 +191,7 @@ TExpandoMenuBar::DetachedFromWindow() message.AddMessenger("messenger", self); be_app->PostMessage(&message); - BMenuItem *item = NULL; - while ((item = RemoveItem(0L)) != NULL) - delete item; + RemoveItems(0, CountItems(), true); } diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp index 925dae3d88..10b9dbd954 100644 --- a/src/apps/deskbar/TeamMenu.cpp +++ b/src/apps/deskbar/TeamMenu.cpp @@ -63,9 +63,7 @@ TTeamMenu::CompareByName(const void *first, const void *second) void TTeamMenu::AttachedToWindow() { - BMenuItem *item = NULL; - while ((item = RemoveItem((int32)0)) != NULL) - delete item; + RemoveItems(0, CountItems(), true); BMessenger self(this); BList teamList;