diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 17:42:44 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 17:42:44 +0000 |
commit | a32eb53d481cd7474049ed902d0fc707e910946d (patch) | |
tree | af669192b3c4b926fd3c77506265504e50ea6172 /views | |
parent | 75a256796767eb2002d46080bf8474eed84cb1d2 (diff) | |
download | chromium_src-a32eb53d481cd7474049ed902d0fc707e910946d.zip chromium_src-a32eb53d481cd7474049ed902d0fc707e910946d.tar.gz chromium_src-a32eb53d481cd7474049ed902d0fc707e910946d.tar.bz2 |
Fix for an error reported by Coverity.
BUG=http://crbug.com/17409
TEST=None
Review URL: http://codereview.chromium.org/160063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/image_button.cc | 16 | ||||
-rw-r--r-- | views/controls/button/image_button.h | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/views/controls/button/image_button.cc b/views/controls/button/image_button.cc index 29f1fe8..50a8f59 100644 --- a/views/controls/button/image_button.cc +++ b/views/controls/button/image_button.cc @@ -18,7 +18,6 @@ static const int kDefaultHeight = 14; // Default button height if no theme. ImageButton::ImageButton(ButtonListener* listener) : CustomButton(listener), - background_image_(NULL), h_alignment_(ALIGN_LEFT), v_alignment_(ALIGN_TOP) { // By default, we request that the gfx::Canvas passed to our View::Paint() @@ -37,11 +36,14 @@ void ImageButton::SetImage(ButtonState aState, SkBitmap* anImage) { void ImageButton::SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask) { - if (!color && !image) - background_image_.reset(NULL); + if (!image || !mask) { + background_image_.reset(); + return; + } - background_image_.reset(new SkBitmap( - skia::ImageOperations::CreateButtonBackground(color, *image, *mask))); + background_image_ = skia::ImageOperations::CreateButtonBackground(color, + *image, + *mask); } void ImageButton::SetImageAlignment(HorizontalAlignment h_align, @@ -79,8 +81,8 @@ void ImageButton::Paint(gfx::Canvas* canvas) { else if (v_alignment_ == ALIGN_BOTTOM) y = height() - img.height(); - if (background_image_.get()) - canvas->DrawBitmapInt(*(background_image_.get()), x, y); + if (!background_image_.empty()) + canvas->DrawBitmapInt(background_image_, x, y); canvas->DrawBitmapInt(img, x, y); } PaintFocusBorder(canvas); diff --git a/views/controls/button/image_button.h b/views/controls/button/image_button.h index f31e3ce..716a67e 100644 --- a/views/controls/button/image_button.h +++ b/views/controls/button/image_button.h @@ -47,7 +47,7 @@ class ImageButton : public CustomButton { SkBitmap images_[BS_COUNT]; // The background image. - scoped_ptr<SkBitmap> background_image_; + SkBitmap background_image_; private: // Image alignment. |