Skip to content

Commit

Permalink
BChannelSlider: Fixed memory leak.
Browse files Browse the repository at this point in the history
At least, I think so.
Check allocations in BChannelSlider::ThumbFor()-
Also updated copyright and e-mail address.
  • Loading branch information
jackburton79 committed Jul 28, 2015
1 parent ef34aca commit 9b78023
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/kits/interface/ChannelSlider.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
* Authors:
* Stefano Ceccherini (burton666@libero.it)
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
* Stephan Aßmus <superstippi@gmx.de>
*/

Expand Down Expand Up @@ -640,18 +640,22 @@ BChannelSlider::DrawThumb(BView* into, int32 channel, BPoint where,
const BBitmap*
BChannelSlider::ThumbFor(int32 channel, bool pressed)
{
// TODO: Finish me (check allocations... etc)
if (fLeftKnob == NULL) {
if (fIsVertical) {
fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 11, 14),
B_CMAP8);
fLeftKnob->SetBits(kVerticalKnobData, sizeof(kVerticalKnobData), 0,
B_CMAP8);
} else {
fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 14, 11),
B_CMAP8);
if (fLeftKnob != NULL)
return fLeftKnob;

if (fIsVertical) {
fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 11, 14),
B_CMAP8);
if (fLeftKnob != NULL) {
fLeftKnob->SetBits(kVerticalKnobData,
sizeof(kVerticalKnobData), 0, B_CMAP8);
}
} else {
fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 14, 11),
B_CMAP8);
if (fLeftKnob != NULL) {
fLeftKnob->SetBits(kHorizontalKnobData,
sizeof(kHorizontalKnobData), 0, B_CMAP8);
sizeof(kHorizontalKnobData), 0, B_CMAP8);
}
}

Expand Down Expand Up @@ -753,13 +757,15 @@ BChannelSlider::_FinishChange(bool update)
if (!fAllChannels) {
inMask = new (std::nothrow) bool[CountChannels()];
if (inMask) {
for (int i=0; i<numChannels; i++)
for (int i = 0; i < numChannels; i++)
inMask[i] = false;
inMask[fCurrentChannel] = true;
}
}
InvokeChannel(update ? ModificationMessage() : NULL, 0, numChannels,
inMask);

delete[] inMask;
}

if (!update) {
Expand Down

0 comments on commit 9b78023

Please sign in to comment.