Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: ui/views/widget/widget.cc

Issue 2839403002: Reland of Don't allow a widget to send close notifications more than once. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index de3ac38f969274531808a3cbb822f406c27cf62d..fbce29ee69aa9f0f31d785434e195aa5e5e9b49d 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -581,26 +581,26 @@
return;
}
- bool can_close = true;
- if (non_client_view_)
- can_close = non_client_view_->CanClose();
- if (can_close) {
- SaveWindowPlacement();
-
- // During tear-down the top-level focus manager becomes unavailable to
- // GTK tabbed panes and their children, so normal deregistration via
- // |FormManager::ViewRemoved()| calls are fouled. We clear focus here
- // to avoid these redundant steps and to avoid accessing deleted views
- // that may have been in focus.
- if (is_top_level() && focus_manager_.get())
- focus_manager_->SetFocusedView(NULL);
-
- for (WidgetObserver& observer : observers_)
- observer.OnWidgetClosing(this);
-
- native_widget_->Close();
- widget_closed_ = true;
- }
+ if (non_client_view_ && !non_client_view_->CanClose())
+ return;
+
+ // The actions below can cause this function to be called again, so mark
+ // |this| as closed early. See crbug.com/714334
+ widget_closed_ = true;
+ SaveWindowPlacement();
+
+ // During tear-down the top-level focus manager becomes unavailable to
+ // GTK tabbed panes and their children, so normal deregistration via
+ // |FocusManager::ViewRemoved()| calls are fouled. We clear focus here
+ // to avoid these redundant steps and to avoid accessing deleted views
+ // that may have been in focus.
+ if (is_top_level() && focus_manager_.get())
+ focus_manager_->SetFocusedView(nullptr);
+
+ for (WidgetObserver& observer : observers_)
+ observer.OnWidgetClosing(this);
+
+ native_widget_->Close();
}
void Widget::CloseNow() {
« no previous file with comments | « no previous file | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698