From cabe514431e61bec8a6deb168a3df17fdb0f13f4 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Fri, 31 Jan 2020 10:27:25 -0800 Subject: [PATCH] chore: add safety checks to RepositionTrafficLights (#21981) --- shell/browser/native_window_mac.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index fea84f1c2614..a02b86139de5 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -523,6 +523,12 @@ void NativeWindowMac::RepositionTrafficLights() { NSButton* miniaturize = [window standardWindowButton:NSWindowMiniaturizeButton]; NSButton* zoom = [window standardWindowButton:NSWindowZoomButton]; + // Safety check just in case apple changes the view structure in a macOS + // update + DCHECK(close.superview); + DCHECK(close.superview.superview); + if (!close.superview || !close.superview.superview) + return; NSView* titleBarContainerView = close.superview.superview; // Hide the container when exiting fullscreen, otherwise traffic light buttons