[haiku-commits] haiku: hrev49471 - src/kits/interface

  • From: stefano.ceccherini@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 28 Jul 2015 21:42:20 +0200 (CEST)

hrev49471 adds 1 changeset to branch 'master'
old head: ef34aca426e42302d299294a5a569a66ff476028
new head: 9b7802354fa49caeff6dcc3b4eb630b5bde692e6
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=9b7802354fa4+%5Eef34aca426e4

----------------------------------------------------------------------------

9b7802354fa4: BChannelSlider: Fixed memory leak.
At least, I think so.
Check allocations in BChannelSlider::ThumbFor()-
Also updated copyright and e-mail address.

[ Stefano Ceccherini <stefano.ceccherini@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision: hrev49471
Commit: 9b7802354fa49caeff6dcc3b4eb630b5bde692e6
URL: http://cgit.haiku-os.org/haiku/commit/?id=9b7802354fa4
Author: Stefano Ceccherini <stefano.ceccherini@xxxxxxxxx>
Date: Tue Jul 28 19:40:21 2015 UTC

----------------------------------------------------------------------------

1 file changed, 20 insertions(+), 14 deletions(-)
src/kits/interface/ChannelSlider.cpp | 34 +++++++++++++++++++-------------

----------------------------------------------------------------------------

diff --git a/src/kits/interface/ChannelSlider.cpp
b/src/kits/interface/ChannelSlider.cpp
index 607ce55..04d8ae5 100644
--- a/src/kits/interface/ChannelSlider.cpp
+++ b/src/kits/interface/ChannelSlider.cpp
@@ -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@xxxxxxxxx)
+ * Stefano Ceccherini (stefano.ceccherini@xxxxxxxxx)
* Stephan Aßmus <superstippi@xxxxxx>
*/

@@ -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);
}
}

@@ -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) {


Other related posts:

  • » [haiku-commits] haiku: hrev49471 - src/kits/interface - stefano . ceccherini