Use BMenu::RemoveItems() instead of looping... I hope I caught all

occurrences.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19910 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-01-23 11:22:12 +00:00
parent aeb2c49f00
commit 4446e07ae9
4 changed files with 8 additions and 33 deletions
+3 -8
View File
@@ -144,16 +144,11 @@ TBarWindow::MenusEnded()
{ {
BWindow::MenusEnded(); BWindow::MenusEnded();
if (!sBeMenu->LockLooper()) { if (sBeMenu->LockLooper()) {
// TODO: is this ok? // 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();
} }
+3 -19
View File
@@ -138,14 +138,7 @@ TBeMenu::DetachedFromWindow()
bool bool
TBeMenu::StartBuildingItemList() TBeMenu::StartBuildingItemList()
{ {
int32 count = CountItems()-1; RemoveItems(0, CountItems(), true);
for (int32 index = count; index >= 0; index--) {
BMenuItem *item = ItemAt(index);
ASSERT(item);
RemoveItem(index);
delete item;
}
fAddState = kStart; fAddState = kStart;
return BNavMenu::StartBuildingItemList(); return BNavMenu::StartBuildingItemList();
} }
@@ -555,14 +548,7 @@ TRecentsMenu::DetachedFromWindow()
bool bool
TRecentsMenu::StartBuildingItemList() TRecentsMenu::StartBuildingItemList()
{ {
int32 count = CountItems()-1; RemoveItems(0, CountItems(), true);
for (int32 index = count; index >= 0; index--) {
BMenuItem *item = ItemAt(index);
ASSERT(item);
RemoveItem(index);
delete item;
}
// !! note: don't call inherited from here // !! note: don't call inherited from here
// the navref is not set for this menu // the navref is not set for this menu
@@ -732,9 +718,7 @@ MountMenu::MountMenu(const char *name)
bool bool
MountMenu::AddDynamicItem(add_state s) MountMenu::AddDynamicItem(add_state s)
{ {
BMenuItem *item; RemoveItems(0, CountItems(), true);
while ((item = RemoveItem(0L)) != NULL)
delete item;
// Send message to tracker to get items. // Send message to tracker to get items.
BMessage request('gmtv'); BMessage request('gmtv');
+1 -3
View File
@@ -191,9 +191,7 @@ TExpandoMenuBar::DetachedFromWindow()
message.AddMessenger("messenger", self); message.AddMessenger("messenger", self);
be_app->PostMessage(&message); be_app->PostMessage(&message);
BMenuItem *item = NULL; RemoveItems(0, CountItems(), true);
while ((item = RemoveItem(0L)) != NULL)
delete item;
} }
+1 -3
View File
@@ -63,9 +63,7 @@ TTeamMenu::CompareByName(const void *first, const void *second)
void void
TTeamMenu::AttachedToWindow() TTeamMenu::AttachedToWindow()
{ {
BMenuItem *item = NULL; RemoveItems(0, CountItems(), true);
while ((item = RemoveItem((int32)0)) != NULL)
delete item;
BMessenger self(this); BMessenger self(this);
BList teamList; BList teamList;