diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-13 18:31:04 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-13 18:31:04 +0000 |
commit | 27477cb0b2ca069b99834771b42860d21e97a1f4 (patch) | |
tree | a5e1e76d0544e73e573b32edb91e13afc31453aa /ui | |
parent | e7d8ea75177be9eeff004599e2e7dd4bd10b4c2f (diff) | |
download | chromium_src-27477cb0b2ca069b99834771b42860d21e97a1f4.zip chromium_src-27477cb0b2ca069b99834771b42860d21e97a1f4.tar.gz chromium_src-27477cb0b2ca069b99834771b42860d21e97a1f4.tar.bz2 |
views: Don't need to explicitly delete ComboboxModelExampleList in the dtor.
Instead of allocating it in the heap store (free store), allocate it on the
stack, avoiding to have to manually delete it in the dtor. Another
possibility would be to use a scoped_ptr here.
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9381034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/examples/examples_window.cc | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/ui/views/examples/examples_window.cc b/ui/views/examples/examples_window.cc index 94725ad..347ddb1 100644 --- a/ui/views/examples/examples_window.cc +++ b/ui/views/examples/examples_window.cc @@ -78,17 +78,14 @@ class ExamplesWindowContents : public WidgetDelegateView, public ComboboxListener { public: explicit ExamplesWindowContents(bool quit_on_close) - : combobox_model_(new ComboboxModelExampleList), - combobox_(new Combobox(combobox_model_)), + : combobox_(new Combobox(&combobox_model_)), example_shown_(new View), status_label_(new Label), quit_on_close_(quit_on_close) { instance_ = this; combobox_->set_listener(this); } - virtual ~ExamplesWindowContents() { - delete combobox_model_; - } + virtual ~ExamplesWindowContents() {} // Prints a message in the status area, at the bottom of the window. void SetStatus(const std::string& status) { @@ -112,7 +109,9 @@ class ExamplesWindowContents : public WidgetDelegateView, } // Overridden from View: - virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) { + virtual void ViewHierarchyChanged(bool is_add, + View* parent, + View* child) OVERRIDE { if (is_add && child == this) InitExamplesWindow(); } @@ -122,9 +121,9 @@ class ExamplesWindowContents : public WidgetDelegateView, int prev_index, int new_index) OVERRIDE { DCHECK(combo_box && combo_box == combobox_); - DCHECK(new_index < combobox_model_->GetItemCount()); + DCHECK(new_index < combobox_model_.GetItemCount()); example_shown_->RemoveAllChildViews(false); - example_shown_->AddChildView(combobox_model_->GetItemViewAt(new_index)); + example_shown_->AddChildView(combobox_model_.GetItemViewAt(new_index)); example_shown_->RequestFocus(); SetStatus(std::string()); Layout(); @@ -146,10 +145,10 @@ class ExamplesWindowContents : public WidgetDelegateView, layout->StartRow(0 /* no expand */, 0); layout->AddView(combobox_); - if (combobox_model_->GetItemCount() > 0) { + if (combobox_model_.GetItemCount() > 0) { layout->StartRow(1, 0); example_shown_->SetLayoutManager(new FillLayout()); - example_shown_->AddChildView(combobox_model_->GetItemViewAt(0)); + example_shown_->AddChildView(combobox_model_.GetItemViewAt(0)); layout->AddView(example_shown_); } @@ -160,32 +159,32 @@ class ExamplesWindowContents : public WidgetDelegateView, // Adds all the individual examples to the combobox model. void AddExamples() { - combobox_model_->AddExample(new TreeViewExample); - combobox_model_->AddExample(new TableExample); - combobox_model_->AddExample(new BubbleExample); - combobox_model_->AddExample(new ButtonExample); - combobox_model_->AddExample(new ComboboxExample); - combobox_model_->AddExample(new DoubleSplitViewExample); - combobox_model_->AddExample(new LinkExample); + combobox_model_.AddExample(new TreeViewExample); + combobox_model_.AddExample(new TableExample); + combobox_model_.AddExample(new BubbleExample); + combobox_model_.AddExample(new ButtonExample); + combobox_model_.AddExample(new ComboboxExample); + combobox_model_.AddExample(new DoubleSplitViewExample); + combobox_model_.AddExample(new LinkExample); #if !defined(USE_AURA) - combobox_model_->AddExample(new MenuExample); + combobox_model_.AddExample(new MenuExample); #endif - combobox_model_->AddExample(new MessageBoxExample); - combobox_model_->AddExample(new NativeThemeButtonExample); - combobox_model_->AddExample(new NativeThemeCheckboxExample); - combobox_model_->AddExample(new ProgressBarExample); - combobox_model_->AddExample(new RadioButtonExample); - combobox_model_->AddExample(new ScrollViewExample); - combobox_model_->AddExample(new SingleSplitViewExample); - combobox_model_->AddExample(new TabbedPaneExample); - combobox_model_->AddExample(new TextExample); - combobox_model_->AddExample(new TextfieldExample); - combobox_model_->AddExample(new ThrobberExample); - combobox_model_->AddExample(new WidgetExample); + combobox_model_.AddExample(new MessageBoxExample); + combobox_model_.AddExample(new NativeThemeButtonExample); + combobox_model_.AddExample(new NativeThemeCheckboxExample); + combobox_model_.AddExample(new ProgressBarExample); + combobox_model_.AddExample(new RadioButtonExample); + combobox_model_.AddExample(new ScrollViewExample); + combobox_model_.AddExample(new SingleSplitViewExample); + combobox_model_.AddExample(new TabbedPaneExample); + combobox_model_.AddExample(new TextExample); + combobox_model_.AddExample(new TextfieldExample); + combobox_model_.AddExample(new ThrobberExample); + combobox_model_.AddExample(new WidgetExample); } static ExamplesWindowContents* instance_; - ComboboxModelExampleList* combobox_model_; + ComboboxModelExampleList combobox_model_; Combobox* combobox_; View* example_shown_; Label* status_label_; |