Tracker: Reduce differences between NavMenu and SlowContextPopup.

No functional change intended.

Change-Id: Iaa9b821462ec97b74de538aa2c489762bf413311
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6872
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Augustin Cavalier
2023-08-28 20:57:26 +00:00
committed by waddlesplash
parent c14bd9b2e7
commit d57510c0ff
2 changed files with 34 additions and 36 deletions
+6 -8
View File
@@ -392,9 +392,7 @@ BNavMenu::ClearMenuBuildingState()
// item list is non-owning, need to delete the items because // item list is non-owning, need to delete the items because
// they didn't get added to the menu // they didn't get added to the menu
if (fItemList != NULL) { if (fItemList != NULL) {
int32 count = fItemList->CountItems(); RemoveItems(0, fItemList->CountItems(), true);
for (int32 index = count - 1; index >= 0; index--)
delete RemoveItem(index);
delete fItemList; delete fItemList;
fItemList = NULL; fItemList = NULL;
@@ -429,14 +427,14 @@ BNavMenu::StartBuildingItemList()
if (startModel.InitCheck() != B_OK || !startModel.IsContainer()) if (startModel.InitCheck() != B_OK || !startModel.IsContainer())
return false; return false;
if (startModel.IsQuery()) if (startModel.IsQuery()) {
fContainer = new QueryEntryListCollection(&startModel); fContainer = new QueryEntryListCollection(&startModel);
else if (startModel.IsVirtualDirectory()) } else if (startModel.IsVirtualDirectory()) {
fContainer = new VirtualDirectoryEntryList(&startModel); fContainer = new VirtualDirectoryEntryList(&startModel);
else if (startModel.IsDesktop()) { } else if (startModel.IsDesktop()) {
fIteratingDesktop = true; fIteratingDesktop = true;
fContainer = DesktopPoseView::InitDesktopDirentIterator( fContainer = DesktopPoseView::InitDesktopDirentIterator(0,
0, startModel.EntryRef()); startModel.EntryRef());
AddRootItemsIfNeeded(); AddRootItemsIfNeeded();
AddTrashItem(); AddTrashItem();
} else if (startModel.IsTrash()) { } else if (startModel.IsTrash()) {
+9 -9
View File
@@ -126,6 +126,7 @@ BSlowContextMenu::DetachedFromWindow()
{ {
// see note above in AttachedToWindow // see note above in AttachedToWindow
fIsShowing = false; fIsShowing = false;
// does this need to set this to null? // does this need to set this to null?
// the parent, handling dnd should set this // the parent, handling dnd should set this
// appropriately // appropriately
@@ -236,11 +237,12 @@ BSlowContextMenu::StartBuildingItemList()
return false; return false;
} }
fItemList = new BObjectList<BMenuItem>(50);
fIteratingDesktop = false; fIteratingDesktop = false;
BDirectory parent; BDirectory parent;
status_t err = entry.GetParent(&parent); status_t err = entry.GetParent(&parent);
fItemList = new BObjectList<BMenuItem>(50);
// if ref is the root item then build list of volume root dirs // if ref is the root item then build list of volume root dirs
fVolsOnly = (err == B_ENTRY_NOT_FOUND); fVolsOnly = (err == B_ENTRY_NOT_FOUND);
@@ -249,15 +251,14 @@ BSlowContextMenu::StartBuildingItemList()
return true; return true;
Model startModel(&entry, true); Model startModel(&entry, true);
if (startModel.InitCheck() == B_OK) { if (startModel.InitCheck() != B_OK || !startModel.IsContainer())
if (!startModel.IsContainer())
return false; return false;
if (startModel.IsQuery()) if (startModel.IsQuery()) {
fContainer = new QueryEntryListCollection(&startModel); fContainer = new QueryEntryListCollection(&startModel);
else if (startModel.IsVirtualDirectory()) } else if (startModel.IsVirtualDirectory()) {
fContainer = new VirtualDirectoryEntryList(&startModel); fContainer = new VirtualDirectoryEntryList(&startModel);
else if (startModel.IsDesktop()) { } else if (startModel.IsDesktop()) {
fIteratingDesktop = true; fIteratingDesktop = true;
fContainer = DesktopPoseView::InitDesktopDirentIterator(0, fContainer = DesktopPoseView::InitDesktopDirentIterator(0,
startModel.EntryRef()); startModel.EntryRef());
@@ -277,7 +278,6 @@ BSlowContextMenu::StartBuildingItemList()
return false; return false;
fContainer->Rewind(); fContainer->Rewind();
}
return true; return true;
} }
@@ -290,13 +290,13 @@ BSlowContextMenu::AddRootItemsIfNeeded()
roster.Rewind(); roster.Rewind();
BVolume volume; BVolume volume;
while (roster.GetNextVolume(&volume) == B_OK) { while (roster.GetNextVolume(&volume) == B_OK) {
BDirectory root; BDirectory root;
BEntry entry; BEntry entry;
if (!volume.IsPersistent() if (!volume.IsPersistent()
|| volume.GetRootDirectory(&root) != B_OK || volume.GetRootDirectory(&root) != B_OK
|| root.GetEntry(&entry) != B_OK) || root.GetEntry(&entry) != B_OK) {
continue; continue;
}
Model model(&entry); Model model(&entry);
AddOneItem(&model); AddOneItem(&model);