summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/browser_window_controller_private.mm
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-22 23:22:09 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-22 23:22:09 +0000
commitd2257faa71ff0bd7bb3766af054e4d6c768b03b3 (patch)
tree47ae74d48ffeccb971d29768a4f0d011e58ac2c7 /chrome/browser/cocoa/browser_window_controller_private.mm
parentf24b87c0b9171b4bfa0a3fdfee7dc56d9d80943e (diff)
downloadchromium_src-d2257faa71ff0bd7bb3766af054e4d6c768b03b3.zip
chromium_src-d2257faa71ff0bd7bb3766af054e4d6c768b03b3.tar.gz
chromium_src-d2257faa71ff0bd7bb3766af054e4d6c768b03b3.tar.bz2
[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
Diffstat (limited to 'chrome/browser/cocoa/browser_window_controller_private.mm')
-rw-r--r--chrome/browser/cocoa/browser_window_controller_private.mm11
1 files changed, 10 insertions, 1 deletions
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(