From d2257faa71ff0bd7bb3766af054e4d6c768b03b3 Mon Sep 17 00:00:00 2001 From: "rohitrao@chromium.org" Date: Mon, 22 Feb 2010 23:22:09 +0000 Subject: [Mac] Fix a crash when switching to a fullscreen window after rearranging monitor positions. BUG=36467 TEST=See test case in bug. Should not crash. Review URL: http://codereview.chromium.org/652061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39660 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/browser_window_controller_private.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'chrome/browser/cocoa/browser_window_controller_private.mm') diff --git a/chrome/browser/cocoa/browser_window_controller_private.mm b/chrome/browser/cocoa/browser_window_controller_private.mm index 6cb72e8..8256bfd 100644 --- a/chrome/browser/cocoa/browser_window_controller_private.mm +++ b/chrome/browser/cocoa/browser_window_controller_private.mm @@ -62,6 +62,15 @@ const CGFloat kFullscreenVerticalBarOffset = 14; // Window positions are stored relative to the origin of the primary monitor. NSRect monitorFrame = [[[NSScreen screens] objectAtIndex:0] frame]; + NSScreen* windowScreen = [window screen]; + + // |windowScreen| can be nil (for example, if the monitor arrangement was + // changed while in fullscreen mode). If we see a nil screen, return without + // saving. + // TODO(rohitrao): We should just not save anything for fullscreen windows. + // http://crbug.com/36479. + if (!windowScreen) + return; // Start with the window's frame, which is in virtual coordinates. // Do some y twiddling to flip the coordinate system. @@ -69,7 +78,7 @@ const CGFloat kFullscreenVerticalBarOffset = 14; bounds.set_y(monitorFrame.size.height - bounds.y() - bounds.height()); // We also need to save the current work area, in flipped coordinates. - gfx::Rect workArea(NSRectToCGRect([[window screen] visibleFrame])); + gfx::Rect workArea(NSRectToCGRect([windowScreen visibleFrame])); workArea.set_y(monitorFrame.size.height - workArea.y() - workArea.height()); DictionaryValue* windowPreferences = prefs->GetMutableDictionary( -- cgit v1.1