[haiku-commits] haiku: hrev43973 - src/apps/deskbar

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 8 Apr 2012 02:38:09 +0200 (CEST)

hrev43973 adds 1 changeset to branch 'master'
old head: 3da13b803853a36868b667a0377237fef9e48e02
new head: 363a49a64e0c4a009b2b9549c117782f2080e39c

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

363a49a: Fix memory leak and an optimization in Deskbar
  
  When resizing Deskbar icons, delete the icon bitmap before rebuilding
  it with a new icon, was leaking the bitmap.
  
  For several actions including:
   - Sorting running apps
   - Setting Tracker first
   - Showing/hiding application expander
   - Expanding new applications
   - Resizing icons
   - Hiding and showing application names
  
  It is not necessary to rebuild all of Deskbar, just rebuild the
  application bar. Should also help but not complete fix Ticket #532.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

Revision:    hrev43973
Commit:      363a49a64e0c4a009b2b9549c117782f2080e39c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=363a49a
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sun Apr  8 00:14:04 2012 UTC

Ticket:      https://dev.haiku-os.org/ticket/532

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

3 files changed, 32 insertions(+), 26 deletions(-)
src/apps/deskbar/BarApp.cpp  |   13 ++++++-----
src/apps/deskbar/BarView.cpp |   40 ++++++++++++++++++++-----------------
src/apps/deskbar/BarView.h   |    5 ++-

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

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index b3308c4..9d45a35 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -453,7 +453,7 @@ TBarApp::MessageReceived(BMessage* message)
                        fSettings.trackerAlwaysFirst = 
!fSettings.trackerAlwaysFirst;
 
                        fBarWindow->Lock();
-                       BarView()->UpdatePlacement();
+                       BarView()->PlaceApplicationBar();
                        fBarWindow->Unlock();
                        break;
 
@@ -461,7 +461,7 @@ TBarApp::MessageReceived(BMessage* message)
                        fSettings.sortRunningApps = !fSettings.sortRunningApps;
 
                        fBarWindow->Lock();
-                       BarView()->UpdatePlacement();
+                       BarView()->PlaceApplicationBar();
                        fBarWindow->Unlock();
                        break;
 
@@ -477,7 +477,7 @@ TBarApp::MessageReceived(BMessage* message)
                        fSettings.superExpando = !fSettings.superExpando;
 
                        fBarWindow->Lock();
-                       BarView()->UpdatePlacement();
+                       BarView()->PlaceApplicationBar();
                        fBarWindow->Unlock();
                        break;
 
@@ -485,7 +485,7 @@ TBarApp::MessageReceived(BMessage* message)
                        fSettings.expandNewTeams = !fSettings.expandNewTeams;
 
                        fBarWindow->Lock();
-                       BarView()->UpdatePlacement();
+                       BarView()->PlaceApplicationBar();
                        fBarWindow->Unlock();
                        break;
 
@@ -493,7 +493,7 @@ TBarApp::MessageReceived(BMessage* message)
                        fSettings.hideLabels = !fSettings.hideLabels;
 
                        fBarWindow->Lock();
-                       BarView()->UpdatePlacement();
+                       BarView()->PlaceApplicationBar();
                        fBarWindow->Unlock();
                        break;
 
@@ -514,7 +514,7 @@ TBarApp::MessageReceived(BMessage* message)
                        ResizeTeamIcons();
 
                        fBarWindow->Lock();
-                       BarView()->UpdatePlacement();
+                       BarView()->PlaceApplicationBar();
                        fBarWindow->Unlock();
                        break;
                }
@@ -759,6 +759,7 @@ TBarApp::ResizeTeamIcons()
                BarTeamInfo* barInfo = (BarTeamInfo*)sBarTeamInfoList.ItemAt(i);
                if ((barInfo->flags & B_BACKGROUND_APP) == 0
                        && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
+                       delete barInfo->icon;
                        barInfo->icon = new BBitmap(IconRect(), kIconFormat);
                        FetchAppIcon(barInfo->sig, barInfo->icon);
                }
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index c588b2c..b15e384 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -315,7 +315,7 @@ TBarView::PlaceDeskbarMenu()
 
 
 void
-TBarView::PlaceTray(bool, bool, BRect screenFrame)
+TBarView::PlaceTray(bool vertSwap, bool leftSwap)
 {
        BPoint statusLoc;
        if (fState == kFullState) {
@@ -346,6 +346,7 @@ TBarView::PlaceTray(bool, bool, BRect screenFrame)
                        else
                                fReplicantTray->MoveTo(2, 2);
                } else {
+                       BRect screenFrame = (BScreen(Window())).Frame();
                        statusLoc.x = screenFrame.right - 
fDragRegion->Bounds().Width();
                        statusLoc.y = -1;
                }
@@ -356,15 +357,23 @@ TBarView::PlaceTray(bool, bool, BRect screenFrame)
 
 
 void
-TBarView::PlaceApplicationBar(BRect screenFrame)
+TBarView::PlaceApplicationBar()
 {
        if (fExpando != NULL) {
+               SaveExpandedItems();
                fExpando->RemoveSelf();
                delete fExpando;
                fExpando = NULL;
        }
-       if (fState == kMiniState)
+
+       BRect screenFrame = (BScreen(Window())).Frame();
+       if (fState == kMiniState) {
+               SizeWindow(screenFrame);
+               PositionWindow(screenFrame);
+               Window()->UpdateIfNeeded();
+               Invalidate();
                return;
+       }
 
        BRect expandoFrame(0, 0, 0, 0);
        if (fVertical) {
@@ -395,6 +404,14 @@ TBarView::PlaceApplicationBar(BRect screenFrame)
        fExpando = new TExpandoMenuBar(this, expandoFrame, "ExpandoMenuBar",
                fVertical, !hideLabels && fState != kFullState);
        AddChild(fExpando);
+
+       if (fVertical)
+               ExpandItems();
+
+       SizeWindow(screenFrame);
+       PositionWindow(screenFrame);
+       Window()->UpdateIfNeeded();
+       Invalidate();
 }
 
 
@@ -531,22 +548,9 @@ TBarView::ChangeState(int32 state, bool vertical, bool 
left, bool top)
        if (stateChanged || vertSwap)
                be_app->PostMessage(kStateChanged);
 
-       BRect screenFrame = (BScreen(Window())).Frame();
-
        PlaceDeskbarMenu();
-       PlaceTray(vertSwap, leftSwap, screenFrame);
-
-       // Keep track of which apps are expanded
-       SaveExpandedItems();
-
-       PlaceApplicationBar(screenFrame);
-       SizeWindow(screenFrame);
-       PositionWindow(screenFrame);
-       Window()->UpdateIfNeeded();
-
-       // Re-expand apps
-       ExpandItems();
-       Invalidate();
+       PlaceTray(vertSwap, leftSwap);
+       PlaceApplicationBar();
 }
 
 
diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
index f222c18..d81d1aa 100644
--- a/src/apps/deskbar/BarView.h
+++ b/src/apps/deskbar/BarView.h
@@ -146,14 +146,15 @@ class TBarView : public BView {
                TReplicantTray* ReplicantTray() const { return fReplicantTray; }
 
        private:
+               friend class TBarApp;
                friend class TDeskbarMenu;
                friend class PreferencesWindow;
 
                status_t SendDragMessage(const char* signature, entry_ref* ref 
= NULL);
 
                void PlaceDeskbarMenu();
-               void PlaceTray(bool vertSwap, bool leftSwap, BRect screenFrame);
-               void PlaceApplicationBar(BRect screenFrame);
+               void PlaceTray(bool vertSwap, bool leftSwap);
+               void PlaceApplicationBar();
                void SaveExpandedItems();
                void RemoveExpandedItems();
                void ExpandItems();


Other related posts:

  • » [haiku-commits] haiku: hrev43973 - src/apps/deskbar - jscipione