diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index cbc8dd943e795..4f193fb3a5ec2 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -447,11 +447,14 @@ void ReorderChildWindowAbove(NSWindow* child_window, NSWindow* other_window) { if ([window_ attachedSheet]) [window_ endSheet:[window_ attachedSheet]]; + // window_ could be nil after performClose. + bool should_notify = is_modal() && parent() && IsVisible(); + [window_ performClose:nil]; // Closing a sheet doesn't trigger windowShouldClose, // so we need to manually call it ourselves here. - if (is_modal() && parent() && IsVisible()) { + if (should_notify) { NotifyWindowCloseButtonClicked(); } }