[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haiku-commits
Subject:    [haiku-commits] haiku: hrev57246 - src/kits/tracker
From:       waddlesplash <waddlesplash () gmail ! com>
Date:       2023-08-28 20:57:29
Message-ID: 20230828205729.14BCB40179 () turing ! freelists ! org
[Download RAW message or body]

hrev57246 adds 1 changeset to branch 'master'
old head: c14bd9b2e7cf490db541587f22514659439aa8e9
new head: d57510c0ff71136ec888ad34abeefad21c3a98e7
overview: https://git.haiku-os.org/haiku/log/?qt=range&q=d57510c0ff71+%5Ec14bd9b2e7cf

----------------------------------------------------------------------------

d57510c0ff71: 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 <waddlesplash@gmail.com>
  Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>

                              [ Augustin Cavalier <waddlesplash@gmail.com> ]

----------------------------------------------------------------------------

Revision:    hrev57246
Commit:      d57510c0ff71136ec888ad34abeefad21c3a98e7
URL:         https://git.haiku-os.org/haiku/commit/?id=d57510c0ff71
Author:      Augustin Cavalier <waddlesplash@gmail.com>
Date:        Fri Aug 25 16:42:19 2023 UTC
Committer:   waddlesplash <waddlesplash@gmail.com>
Commit-Date: Mon Aug 28 20:57:26 2023 UTC

----------------------------------------------------------------------------

2 files changed, 34 insertions(+), 36 deletions(-)
src/kits/tracker/NavMenu.cpp          | 14 ++++----
src/kits/tracker/SlowContextPopup.cpp | 56 +++++++++++++++----------------

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/NavMenu.cpp b/src/kits/tracker/NavMenu.cpp
index afdc3c32ac..959125b518 100644
--- a/src/kits/tracker/NavMenu.cpp
+++ b/src/kits/tracker/NavMenu.cpp
@@ -392,9 +392,7 @@ BNavMenu::ClearMenuBuildingState()
 	// item list is non-owning, need to delete the items because
 	// they didn't get added to the menu
 	if (fItemList != NULL) {
-		int32 count = fItemList->CountItems();
-		for (int32 index = count - 1; index >= 0; index--)
-			delete RemoveItem(index);
+		RemoveItems(0, fItemList->CountItems(), true);
 
 		delete fItemList;
 		fItemList = NULL;
@@ -429,14 +427,14 @@ BNavMenu::StartBuildingItemList()
 	if (startModel.InitCheck() != B_OK || !startModel.IsContainer())
 		return false;
 
-	if (startModel.IsQuery())
+	if (startModel.IsQuery()) {
 		fContainer = new QueryEntryListCollection(&startModel);
-	else if (startModel.IsVirtualDirectory())
+	} else if (startModel.IsVirtualDirectory()) {
 		fContainer = new VirtualDirectoryEntryList(&startModel);
-	else if (startModel.IsDesktop()) {
+	} else if (startModel.IsDesktop()) {
 		fIteratingDesktop = true;
-		fContainer = DesktopPoseView::InitDesktopDirentIterator(
-			0, 	startModel.EntryRef());
+		fContainer = DesktopPoseView::InitDesktopDirentIterator(0,
+			startModel.EntryRef());
 		AddRootItemsIfNeeded();
 		AddTrashItem();
 	} else if (startModel.IsTrash()) {
diff --git a/src/kits/tracker/SlowContextPopup.cpp b/src/kits/tracker/SlowContextPopup.cpp
index 8876a97330..bd73972a3f 100644
--- a/src/kits/tracker/SlowContextPopup.cpp
+++ b/src/kits/tracker/SlowContextPopup.cpp
@@ -126,6 +126,7 @@ BSlowContextMenu::DetachedFromWindow()
 {
 	// see note above in AttachedToWindow
 	fIsShowing = false;
+
 	// does this need to set this to null?
 	// the parent, handling dnd should set this
 	// appropriately
@@ -236,11 +237,12 @@ BSlowContextMenu::StartBuildingItemList()
 		return false;
 	}
 
+	fItemList = new BObjectList<BMenuItem>(50);
+
 	fIteratingDesktop = false;
 
 	BDirectory 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
 	fVolsOnly = (err == B_ENTRY_NOT_FOUND);
@@ -249,36 +251,34 @@ BSlowContextMenu::StartBuildingItemList()
 		return true;
 
 	Model startModel(&entry, true);
-	if (startModel.InitCheck() == B_OK) {
-		if (!startModel.IsContainer())
-			return false;
+	if (startModel.InitCheck() != B_OK || !startModel.IsContainer())
+		return false;
 
-		if (startModel.IsQuery())
-			fContainer = new QueryEntryListCollection(&startModel);
-		else if (startModel.IsVirtualDirectory())
-			fContainer = new VirtualDirectoryEntryList(&startModel);
-		else if (startModel.IsDesktop()) {
-			fIteratingDesktop = true;
-			fContainer = DesktopPoseView::InitDesktopDirentIterator(0,
-				startModel.EntryRef());
-			AddRootItemsIfNeeded();
-			AddTrashItem();
-		} else {
-			BDirectory* directory = dynamic_cast<BDirectory*>(
-				startModel.Node());
-
-			ASSERT(directory != NULL);
-
-			if (directory != NULL)
-				fContainer = new DirectoryEntryList(*directory);
-		}
+	if (startModel.IsQuery()) {
+		fContainer = new QueryEntryListCollection(&startModel);
+	} else if (startModel.IsVirtualDirectory()) {
+		fContainer = new VirtualDirectoryEntryList(&startModel);
+	} else if (startModel.IsDesktop()) {
+		fIteratingDesktop = true;
+		fContainer = DesktopPoseView::InitDesktopDirentIterator(0,
+			startModel.EntryRef());
+		AddRootItemsIfNeeded();
+		AddTrashItem();
+	} else {
+		BDirectory* directory = dynamic_cast<BDirectory*>(
+			startModel.Node());
 
-		if (fContainer->InitCheck() != B_OK)
-			return false;
+		ASSERT(directory != NULL);
 
-		fContainer->Rewind();
+		if (directory != NULL)
+			fContainer = new DirectoryEntryList(*directory);
 	}
 
+	if (fContainer->InitCheck() != B_OK)
+		return false;
+
+	fContainer->Rewind();
+
 	return true;
 }
 
@@ -290,13 +290,13 @@ BSlowContextMenu::AddRootItemsIfNeeded()
 	roster.Rewind();
 	BVolume volume;
 	while (roster.GetNextVolume(&volume) == B_OK) {
-
 		BDirectory root;
 		BEntry entry;
 		if (!volume.IsPersistent()
 			|| volume.GetRootDirectory(&root) != B_OK
-			|| root.GetEntry(&entry) != B_OK)
+			|| root.GetEntry(&entry) != B_OK) {
 			continue;
+		}
 
 		Model model(&entry);
 		AddOneItem(&model);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic