BChannelSlider: Fixed memory leak.

At least, I think so.
Check allocations in BChannelSlider::ThumbFor()-
Also updated copyright and e-mail address.
This commit is contained in:
Stefano Ceccherini
2015-07-28 21:40:21 +02:00
parent ef34aca426
commit 9b7802354f
+12 -6
View File
@@ -1,9 +1,9 @@
/* /*
* Copyright 2005-2009, Haiku Inc. All Rights Reserved. * Copyright 2005-2015, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Stefano Ceccherini ([email protected]) * Stefano Ceccherini ([email protected])
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
*/ */
@@ -640,16 +640,20 @@ BChannelSlider::DrawThumb(BView* into, int32 channel, BPoint where,
const BBitmap* const BBitmap*
BChannelSlider::ThumbFor(int32 channel, bool pressed) BChannelSlider::ThumbFor(int32 channel, bool pressed)
{ {
// TODO: Finish me (check allocations... etc) if (fLeftKnob != NULL)
if (fLeftKnob == NULL) { return fLeftKnob;
if (fIsVertical) { if (fIsVertical) {
fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 11, 14), fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 11, 14),
B_CMAP8); B_CMAP8);
fLeftKnob->SetBits(kVerticalKnobData, sizeof(kVerticalKnobData), 0, if (fLeftKnob != NULL) {
B_CMAP8); fLeftKnob->SetBits(kVerticalKnobData,
sizeof(kVerticalKnobData), 0, B_CMAP8);
}
} else { } else {
fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 14, 11), fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 14, 11),
B_CMAP8); B_CMAP8);
if (fLeftKnob != NULL) {
fLeftKnob->SetBits(kHorizontalKnobData, fLeftKnob->SetBits(kHorizontalKnobData,
sizeof(kHorizontalKnobData), 0, B_CMAP8); sizeof(kHorizontalKnobData), 0, B_CMAP8);
} }
@@ -760,6 +764,8 @@ BChannelSlider::_FinishChange(bool update)
} }
InvokeChannel(update ? ModificationMessage() : NULL, 0, numChannels, InvokeChannel(update ? ModificationMessage() : NULL, 0, numChannels,
inMask); inMask);
delete[] inMask;
} }
if (!update) { if (!update) {