diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 15:10:16 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 15:10:16 +0000 |
commit | 360a2224ced62f775b1a1b908b6a015df3f071e3 (patch) | |
tree | ffb3d146bbc156126ec9d6d1757dd8ab50c16dac | |
parent | d560c6f5a89c582c9e12000adcebb4d4538a665d (diff) | |
download | chromium_src-360a2224ced62f775b1a1b908b6a015df3f071e3.zip chromium_src-360a2224ced62f775b1a1b908b6a015df3f071e3.tar.gz chromium_src-360a2224ced62f775b1a1b908b6a015df3f071e3.tar.bz2 |
views: Fix memory leak in NativeThemeButtonExample.
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9945001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129858 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/views/examples/native_theme_button_example.cc | 16 | ||||
-rw-r--r-- | ui/views/examples/native_theme_button_example.h | 12 |
2 files changed, 17 insertions, 11 deletions
diff --git a/ui/views/examples/native_theme_button_example.cc b/ui/views/examples/native_theme_button_example.cc index 9e38467..d796ba8 100644 --- a/ui/views/examples/native_theme_button_example.cc +++ b/ui/views/examples/native_theme_button_example.cc @@ -220,21 +220,23 @@ void NativeThemeButtonExample::CreateExampleView(View* container) { layout->StartRow(0, 0); layout->AddView(new Label(ASCIIToUTF16("Part:"))); - Combobox* cb_part = new Combobox( + combobox_model_part_.reset( new ExampleComboboxModel(kParts, arraysize(kParts))); - cb_part->SetSelectedIndex(0); - layout->AddView(cb_part); + Combobox* combobox_part = new Combobox(combobox_model_part_.get()); + combobox_part->SetSelectedIndex(0); + layout->AddView(combobox_part); layout->StartRow(0, 0); layout->AddView(new Label(ASCIIToUTF16("State:"))); - Combobox* cb_state = new Combobox( + combobox_model_state_.reset( new ExampleComboboxModel(kStates, arraysize(kStates))); - cb_state->SetSelectedIndex(0); - layout->AddView(cb_state); + Combobox* combobox_state = new Combobox(combobox_model_state_.get()); + combobox_state->SetSelectedIndex(0); + layout->AddView(combobox_state); layout->AddPaddingRow(0, 32); - button_ = new ExampleNativeThemeButton(this, cb_part, cb_state); + button_ = new ExampleNativeThemeButton(this, combobox_part, combobox_state); column_set = layout->AddColumnSet(1); column_set->AddPaddingColumn(0, 16); diff --git a/ui/views/examples/native_theme_button_example.h b/ui/views/examples/native_theme_button_example.h index 9896818..862443a 100644 --- a/ui/views/examples/native_theme_button_example.h +++ b/ui/views/examples/native_theme_button_example.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,12 +7,12 @@ #pragma once #include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" #include "ui/gfx/native_theme.h" #include "ui/views/controls/button/custom_button.h" #include "ui/views/controls/combobox/combobox_listener.h" #include "ui/views/examples/example_base.h" #include "ui/views/native_theme_delegate.h" -#include "ui/views/native_theme_painter.h" namespace views { class Combobox; @@ -20,6 +20,8 @@ class NativeThemePainter; namespace examples { +class ExampleComboboxModel; + // A subclass of button to test native theme rendering. class ExampleNativeThemeButton : public CustomButton, public NativeThemeDelegate, @@ -42,7 +44,7 @@ class ExampleNativeThemeButton : public CustomButton, int prev_index, int new_index) OVERRIDE; - // Overridden from NativeThemePainter::Delegate: + // Overridden from NativeThemeDelegate: virtual gfx::NativeTheme::Part GetThemePart() const OVERRIDE; virtual gfx::Rect GetThemePaintRect() const OVERRIDE; virtual gfx::NativeTheme::State GetThemeState( @@ -79,9 +81,11 @@ class NativeThemeButtonExample : public ExampleBase, public ButtonListener { // Overridden from ButtonListener: virtual void ButtonPressed(Button* sender, const Event& event) OVERRIDE; - // The only control in this test. ExampleNativeThemeButton* button_; + scoped_ptr<ExampleComboboxModel> combobox_model_part_; + scoped_ptr<ExampleComboboxModel> combobox_model_state_; + DISALLOW_COPY_AND_ASSIGN(NativeThemeButtonExample); }; |