diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 01:24:56 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 01:24:56 +0000 |
commit | 7d778fb3afe9eb0da4ea3c13856491efea43cdde (patch) | |
tree | 2520b6553273bdcf8f3b5322e1b67356d87e8c6e /ui/views/controls/combobox | |
parent | 561ddce5b44c0c4d5e9d918da00a451f6c828708 (diff) | |
download | chromium_src-7d778fb3afe9eb0da4ea3c13856491efea43cdde.zip chromium_src-7d778fb3afe9eb0da4ea3c13856491efea43cdde.tar.gz chromium_src-7d778fb3afe9eb0da4ea3c13856491efea43cdde.tar.bz2 |
ui/base/models: Add protected virtual destructor to ComboboxModel.
The use of a protected virtual destructor is to prevent the destruction of a
derived object via a base-class pointer.
That's it, ComboboxModel should only be deleted through derived class.
Example 1:
class FooComboboxModel : public ComboboxModel {
};
ComboboxModel* model = new FooComboboxModel;
delete model; // It should prevent this situation!
Also, a protected virtual destructor makes it clear that someone else owns the
object.
Example 2:
class Foo {
public:
void SetModel(ComboboxModel* model);
};
If you see that the model has a protected destructor, you know Foo doesn't own
|model|.
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9817007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128132 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/controls/combobox')
-rw-r--r-- | ui/views/controls/combobox/native_combobox_views_unittest.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ui/views/controls/combobox/native_combobox_views_unittest.cc b/ui/views/controls/combobox/native_combobox_views_unittest.cc index caa1275..2474c4a 100644 --- a/ui/views/controls/combobox/native_combobox_views_unittest.cc +++ b/ui/views/controls/combobox/native_combobox_views_unittest.cc @@ -135,14 +135,14 @@ class NativeComboboxViewsTest : public ViewsTestBase { // We need widget to populate wrapper class. Widget* widget_; - // combobox_ will be allocated InitCombobox() and then owned by widget_. + // |combobox_| will be allocated InitCombobox() and then owned by |widget_|. TestCombobox* combobox_; - // combobox_view_ is the pointer to the pure Views interface of combobox_. + // |combobox_view_| is the pointer to the pure Views interface of |combobox_|. NativeComboboxViews* combobox_view_; - // Combobox does not take ownership of model_, which needs to be scoped. - scoped_ptr<ui::ComboboxModel> model_; + // Combobox does not take ownership of the model, hence it needs to be scoped. + scoped_ptr<TestComboboxModel> model_; // For testing input method related behaviors. MockInputMethod* input_method_; |