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.
This commit is contained in:
parent
3da13b8038
commit
363a49a64e
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue