Revert "Deskbar: Avoid leaking leaf bitmap's memory"

This reverts commit 223ea4329f.
This commit is contained in:
John Scipione
2017-01-09 02:31:38 -08:00
parent da6286856f
commit 2154128845
2 changed files with 5 additions and 27 deletions
+5 -24
View File
@@ -37,7 +37,6 @@ All rights reserved.
#include "BarMenuTitle.h"
#include <algorithm>
#include <new>
#include <Bitmap.h>
#include <ControlLook.h>
@@ -156,6 +155,7 @@ TBarMenuTitle::Invoke(BMessage* message)
void
TBarMenuTitle::SetIcon(const BBitmap* icon)
{
delete fIcon;
fIcon = icon;
}
@@ -177,20 +177,6 @@ TDeskbarMenuTitle::TDeskbarMenuTitle(float width, float height,
}
TDeskbarMenuTitle::~TDeskbarMenuTitle()
{
delete fIcon;
}
void
TDeskbarMenuTitle::SetIcon(const BBitmap* icon)
{
delete fIcon;
fIcon = icon;
}
void
TDeskbarMenuTitle::DrawContent()
{
@@ -226,21 +212,16 @@ TDeskbarMenuTitle::FetchIcon()
}
float width = CalcIconWidth();
BBitmap* icon = new(std::nothrow) BBitmap(BRect(0, 0, width - 1, width - 1),
BBitmap* icon = new BBitmap(BRect(0, 0, width - 1, width - 1),
B_RGBA32);
if (fVectorIconData != NULL && fVectorIconSize > 0 && icon != NULL
if (fVectorIconData != NULL && fVectorIconSize > 0
&& BIconUtils::GetVectorIcon(fVectorIconData, fVectorIconSize, icon)
== B_OK) {
// rasterized vector icon into a bitmap
SetIcon(icon);
fIcon = icon;
} else {
// fetched bitmap instead
const BBitmap* leaf = AppResSet()->FindBitmap(B_MESSAGE_TYPE,
R_LeafLogoBitmap);
// make a copy of the leaf bitmap that we can safely delete
BBitmap* leafCopy = new BBitmap(leaf->Bounds(), leaf->ColorSpace());
leafCopy->ImportBits(leaf);
SetIcon(leafCopy);
fIcon = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap);
// TODO: scale the bitmap into icon
delete icon;
}
-3
View File
@@ -76,9 +76,6 @@ class TDeskbarMenuTitle : public TBarMenuTitle {
public:
TDeskbarMenuTitle(float width, float height,
const BBitmap* icon, BMenu* menu);
virtual ~TDeskbarMenuTitle();
virtual void SetIcon(const BBitmap* icon);
virtual void DrawContent();