IconButton.cpp: fix memory leak.
Signed-off-by: Adrien Destugues <[email protected]> Ticket : #13127
This commit is contained in:
committed by
Adrien Destugues
parent
b50d53dd19
commit
682adeb3aa
@@ -448,9 +448,9 @@ BIconButton::SetIcon(const unsigned char* bitsFromQuickRes,
|
|||||||
BBitmap* bitmap = new(std::nothrow) BBitmap(
|
BBitmap* bitmap = new(std::nothrow) BBitmap(
|
||||||
quickResBitmap->Bounds(), B_RGB32, true);
|
quickResBitmap->Bounds(), B_RGB32, true);
|
||||||
if (bitmap && bitmap->IsValid()) {
|
if (bitmap && bitmap->IsValid()) {
|
||||||
|
if (bitmap->Lock()) {
|
||||||
BView* helper = new BView(bitmap->Bounds(), "helper",
|
BView* helper = new BView(bitmap->Bounds(), "helper",
|
||||||
B_FOLLOW_NONE, B_WILL_DRAW);
|
B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
if (bitmap->Lock()) {
|
|
||||||
bitmap->AddChild(helper);
|
bitmap->AddChild(helper);
|
||||||
helper->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
helper->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
helper->FillRect(helper->Bounds());
|
helper->FillRect(helper->Bounds());
|
||||||
@@ -664,9 +664,9 @@ BIconButton::_ConvertToRGB32(const BBitmap* bitmap) const
|
|||||||
B_BITMAP_ACCEPTS_VIEWS, B_RGBA32);
|
B_BITMAP_ACCEPTS_VIEWS, B_RGBA32);
|
||||||
if (convertedBitmap && convertedBitmap->IsValid()) {
|
if (convertedBitmap && convertedBitmap->IsValid()) {
|
||||||
memset(convertedBitmap->Bits(), 0, convertedBitmap->BitsLength());
|
memset(convertedBitmap->Bits(), 0, convertedBitmap->BitsLength());
|
||||||
|
if (convertedBitmap->Lock()) {
|
||||||
BView* helper = new BView(bitmap->Bounds(), "helper",
|
BView* helper = new BView(bitmap->Bounds(), "helper",
|
||||||
B_FOLLOW_NONE, B_WILL_DRAW);
|
B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
if (convertedBitmap->Lock()) {
|
|
||||||
convertedBitmap->AddChild(helper);
|
convertedBitmap->AddChild(helper);
|
||||||
helper->SetDrawingMode(B_OP_OVER);
|
helper->SetDrawingMode(B_OP_OVER);
|
||||||
helper->DrawBitmap(bitmap, BPoint(0.0, 0.0));
|
helper->DrawBitmap(bitmap, BPoint(0.0, 0.0));
|
||||||
|
|||||||
Reference in New Issue
Block a user