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

Unified Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 2090003002: MacViews: Explicitly release mouse capture in BridgedNativeWidget::OnWindowWillClose(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 6 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_interactive_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_native_widget.mm
diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
index 47373d0d4a973470d3ddc37c590af7672d842173..6ea619b9330a6a2e06602eb4ddf425f80d94a23a 100644
--- a/ui/views/cocoa/bridged_native_widget.mm
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -674,6 +674,14 @@ void BridgedNativeWidget::SetCursor(NSCursor* cursor) {
}
void BridgedNativeWidget::OnWindowWillClose() {
+ // Ensure BridgedNativeWidget does not have capture, otherwise
+ // OnMouseCaptureLost() may reference a deleted |native_widget_mac_| when
+ // called via ~CocoaMouseCapture() upon the destruction of |mouse_capture_|.
+ // See crbug.com/622201. Also we do this before setting the delegate to nil,
+ // because this may lead to callbacks to bridge which rely on a valid
+ // delegate.
+ ReleaseCapture();
+
if (parent_) {
parent_->RemoveChildWindow(this);
parent_ = nullptr;
@@ -795,7 +803,7 @@ void BridgedNativeWidget::OnVisibilityChangedTo(bool new_visibility) {
if (parent_)
[parent_->GetNSWindow() addChildWindow:window_ ordered:NSWindowAbove];
} else {
- mouse_capture_.reset(); // Capture on hidden windows is not permitted.
+ ReleaseCapture(); // Capture on hidden windows is not permitted.
// When becoming invisible, remove the entry in any parent's childWindow
// list. Cocoa's childWindow management breaks down when child windows are
« no previous file with comments | « no previous file | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698