Commit 8deb1ff3 authored by mirandac@chromium.org's avatar mirandac@chromium.org

Fix memory leak in ImageButton exposed by r20028.

BUG= none.
TEST= none.

Review URL: http://codereview.chromium.org/149313

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20134 0039d316-1c4b-4281-b951-d872f2087c98
parent d0691ffc
...@@ -38,10 +38,10 @@ void ImageButton::SetBackground(SkColor color, ...@@ -38,10 +38,10 @@ void ImageButton::SetBackground(SkColor color,
SkBitmap* image, SkBitmap* image,
SkBitmap* mask) { SkBitmap* mask) {
if (!color && !image) if (!color && !image)
background_image_ = NULL; background_image_.reset(NULL);
background_image_ = new SkBitmap( background_image_.reset(new SkBitmap(
skia::ImageOperations::CreateButtonBackground(color, *image, *mask)); skia::ImageOperations::CreateButtonBackground(color, *image, *mask)));
} }
void ImageButton::SetImageAlignment(HorizontalAlignment h_align, void ImageButton::SetImageAlignment(HorizontalAlignment h_align,
...@@ -79,8 +79,8 @@ void ImageButton::Paint(gfx::Canvas* canvas) { ...@@ -79,8 +79,8 @@ void ImageButton::Paint(gfx::Canvas* canvas) {
else if (v_alignment_ == ALIGN_BOTTOM) else if (v_alignment_ == ALIGN_BOTTOM)
y = height() - img.height(); y = height() - img.height();
if (background_image_) if (background_image_.get())
canvas->DrawBitmapInt(*background_image_, x, y); canvas->DrawBitmapInt(*(background_image_.get()), x, y);
canvas->DrawBitmapInt(img, x, y); canvas->DrawBitmapInt(img, x, y);
} }
PaintFocusBorder(canvas); PaintFocusBorder(canvas);
......
...@@ -47,7 +47,7 @@ class ImageButton : public CustomButton { ...@@ -47,7 +47,7 @@ class ImageButton : public CustomButton {
SkBitmap images_[BS_COUNT]; SkBitmap images_[BS_COUNT];
// The background image. // The background image.
SkBitmap* background_image_; scoped_ptr<SkBitmap> background_image_;
private: private:
// Image alignment. // Image alignment.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment