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

List:       haiku-commits
Subject:    [haiku-commits] haiku: hrev57056 - src/kits/tracker
From:       waddlesplash <waddlesplash () gmail ! com>
Date:       2023-05-31 17:48:20
Message-ID: 20230531174820.9FEF54079F () turing ! freelists ! org
[Download RAW message or body]

hrev57056 adds 1 changeset to branch 'master'
old head: ef8e820bc711ee56d79a8c75d9a3aa2a7de4210e
new head: 338fedd65a5bc57f3ec35b9c0d48ab5d8b013bd3
overview: https://git.haiku-os.org/haiku/log/?qt=range&q=338fedd65a5b+%5Eef8e820bc711

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

338fedd65a5b: Tracker: Fix memory leak
  
  BMenuField's constructor (called on line 715) used to be passed
  fDirMenu. The constructor would create a new BMenuItem using fDirMenu.
  TFilePanel::Init did not want this menu so it removed it with a call to
  RemoveItem (located on line 721). This call, however, does not actually
  free the memory. It just removes it from the menu. The refactor that I
  did here fixes this by never creating the new BMenuItem in the first
  place. This is done by passing NULL into BMenuField's constructor
  instead of fDirMenu. It happens that the refactoring also cleans up
  TFilePanel::Init slightly.
  
  Change-Id: I05ef24f429fb309ff41806e342d275f832772b5e
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/6486
  Reviewed-by: waddlesplash <waddlesplash@gmail.com>

                                  [ Zardshard <0azrune6@zard.anonaddy.com> ]

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

Revision:    hrev57056
Commit:      338fedd65a5bc57f3ec35b9c0d48ab5d8b013bd3
URL:         https://git.haiku-os.org/haiku/commit/?id=338fedd65a5b
Author:      Zardshard <0azrune6@zard.anonaddy.com>
Date:        Wed May 31 17:00:37 2023 UTC
Committer:   waddlesplash <waddlesplash@gmail.com>
Commit-Date: Wed May 31 17:48:17 2023 UTC

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

1 file changed, 3 insertions(+), 7 deletions(-)
src/kits/tracker/FilePanelPriv.cpp | 10 +++-------

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

diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp
index e2297e3e80..8e9955cf1c 100644
--- a/src/kits/tracker/FilePanelPriv.cpp
+++ b/src/kits/tracker/FilePanelPriv.cpp
@@ -699,8 +699,6 @@ TFilePanel::Init(const BMessage*)
 	fBackView->AddChild(fMenuBar);
 
 	// add directory menu and menufield
-	fDirMenu = new BDirMenu(0, this, kSwitchDirectory, "refs");
-
 	font_height ht;
 	be_plain_font->GetHeight(&ht);
 	const float f_height = ht.ascent + ht.descent + ht.leading;
@@ -712,16 +710,14 @@ TFilePanel::Init(const BMessage*)
 	rect.right = rect.left + (spacing * 50);
 	rect.bottom = rect.top + (f_height > 22 ? f_height : 22);
 
-	fDirMenuField = new BMenuField(rect, "DirMenuField", "", fDirMenu);
+	fDirMenuField = new BMenuField(rect, "DirMenuField", "", NULL);
 	fDirMenuField->MenuBar()->SetFont(be_plain_font);
 	fDirMenuField->SetDivider(0);
 	fDirMenuField->MenuBar()->SetMaxContentWidth(rect.Width() - 26.0f);
 		// Make room for the icon
 
-	fDirMenuField->MenuBar()->RemoveItem((int32)0);
-	fDirMenu->SetMenuBar(fDirMenuField->MenuBar());
-		// the above is a weird call from BDirMenu
-		// ToDo: clean up
+	fDirMenu = new BDirMenu(fDirMenuField->MenuBar(),
+		this, kSwitchDirectory, "refs");
 
 	BEntry entry(TargetModel()->EntryRef());
 	if (entry.InitCheck() == B_OK)


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

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