From 603aa0fbe73299c2204d24d1f9a09cf611c464ac Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Wed, 10 Jun 2009 23:05:22 +0000 Subject: Restricts the creation of RadioButton to specify an group-id. The API is dangerous without one, has it will probably collide with other non radio-button views. BUG=None TEST=None Review URL: http://codereview.chromium.org/120002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18110 0039d316-1c4b-4281-b951-d872f2087c98 --- views/controls/button/radio_button.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'views/controls/button/radio_button.cc') diff --git a/views/controls/button/radio_button.cc b/views/controls/button/radio_button.cc index 3f4820d..744dbe1 100644 --- a/views/controls/button/radio_button.cc +++ b/views/controls/button/radio_button.cc @@ -4,6 +4,7 @@ #include "views/controls/button/radio_button.h" +#include "base/logging.h" #include "views/widget/root_view.h" namespace views { @@ -14,12 +15,6 @@ const char RadioButton::kViewClassName[] = "views/RadioButton"; //////////////////////////////////////////////////////////////////////////////// // RadioButton, public: -RadioButton::RadioButton() : Checkbox() { -} - -RadioButton::RadioButton(const std::wstring& label) : Checkbox(label) { -} - RadioButton::RadioButton(const std::wstring& label, int group_id) : Checkbox(label) { SetGroup(group_id); @@ -47,6 +42,11 @@ void RadioButton::SetChecked(bool checked) { std::vector::iterator i; for (i = other.begin(); i != other.end(); ++i) { if (*i != this) { + if ((*i)->GetClassName() != kViewClassName) { + NOTREACHED() << "radio-button has same group as other non " + "radio-button views."; + continue; + } RadioButton* peer = static_cast(*i); peer->SetChecked(false); } -- cgit v1.1