Chromium Code Reviews| Index: ui/views/window/dialog_client_view.cc |
| diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc |
| index 08d2cfc4996faacbbc6f01f1975bbce9ecfba884..bb24e7c80b480d9302663a3a8e0692341d75c84c 100644 |
| --- a/ui/views/window/dialog_client_view.cc |
| +++ b/ui/views/window/dialog_client_view.cc |
| @@ -43,9 +43,6 @@ DialogClientView::DialogClientView(Widget* owner, View* contents_view) |
| } |
| DialogClientView::~DialogClientView() { |
| - if (focus_manager_) |
| - focus_manager_->RemoveFocusChangeListener(this); |
| - focus_manager_ = NULL; |
| } |
| void DialogClientView::AcceptWindow() { |
| @@ -73,13 +70,14 @@ void DialogClientView::UpdateDialogButtons() { |
| if (buttons & ui::DIALOG_BUTTON_OK) { |
| if (!ok_button_) { |
| ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK); |
| - if (buttons & ui::DIALOG_BUTTON_CANCEL) |
| + if (!(buttons & ui::DIALOG_BUTTON_CANCEL)) |
| ok_button_->AddAccelerator(escape); |
| AddChildView(ok_button_); |
| } |
| UpdateButton(ok_button_, ui::DIALOG_BUTTON_OK); |
| } else if (ok_button_) { |
| + RemoveChildView(ok_button_); |
|
sky
2013/06/17 20:30:14
Is there a particular reason you are adding this?
msw
2013/06/17 21:10:56
Ah, solely out of ignorance; updated this and simp
|
| delete ok_button_; |
| ok_button_ = NULL; |
| } |
| @@ -93,6 +91,7 @@ void DialogClientView::UpdateDialogButtons() { |
| UpdateButton(cancel_button_, ui::DIALOG_BUTTON_CANCEL); |
| } else if (cancel_button_) { |
| + RemoveChildView(cancel_button_); |
| delete cancel_button_; |
| cancel_button_ = NULL; |
| } |
| @@ -272,6 +271,17 @@ void DialogClientView::ViewHierarchyChanged( |
| UpdateDialogButtons(); |
| CreateExtraView(); |
| CreateFootnoteView(); |
| + } else if (!details.is_add && details.child == this) { |
| + if (focus_manager_) |
| + focus_manager_->RemoveFocusChangeListener(this); |
| + focus_manager_ = NULL; |
| + } else if (!details.is_add) { |
| + if (details.child == default_button_) |
| + default_button_ = NULL; |
| + if (details.child == ok_button_) |
| + ok_button_ = NULL; |
| + if (details.child == cancel_button_) |
| + cancel_button_ = NULL; |
| } |
| } |