summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-11 00:39:39 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-11 00:39:39 +0000
commitb5e8a7f62ba4037c1a30d861a4a5de3a80fa1de0 (patch)
tree0f0347079bfa905157a679ed964057e09679ab48 /chrome
parent34e53fa8c19c8b5578ab8f1c7f073feb9807dba1 (diff)
downloadchromium_src-b5e8a7f62ba4037c1a30d861a4a5de3a80fa1de0.zip
chromium_src-b5e8a7f62ba4037c1a30d861a4a5de3a80fa1de0.tar.gz
chromium_src-b5e8a7f62ba4037c1a30d861a4a5de3a80fa1de0.tar.bz2
[Mac] If an info bubble window is open when the app is terminating, cancel the fadeout animation to prevent the window object from leaking.
BUG=37717 TEST=none Review URL: http://codereview.chromium.org/822007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41229 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/info_bubble_window.mm36
1 files changed, 34 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/info_bubble_window.mm b/chrome/browser/cocoa/info_bubble_window.mm
index 80c0b8d..ebfe94c 100644
--- a/chrome/browser/cocoa/info_bubble_window.mm
+++ b/chrome/browser/cocoa/info_bubble_window.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,9 +12,15 @@ namespace {
const CGFloat kOrderInSlideOffset = 10;
const NSTimeInterval kOrderInAnimationDuration = 0.2;
const NSTimeInterval kOrderOutAnimationDuration = 0.15;
+// The minimum representable time interval. This can be used as the value
+// passed to +[NSAnimationContext setDuration:] to stop an in-progress
+// animation as quickly as possible.
+const NSTimeInterval kMinimumTimeInterval =
+ std::numeric_limits<NSTimeInterval>::min();
}
-@interface InfoBubbleWindow (Private)
+@interface InfoBubbleWindow(Private)
+- (void)appIsTerminating;
- (void)finishCloseAfterAnimation;
@end
@@ -83,10 +89,21 @@ const NSTimeInterval kOrderOutAnimationDuration = 0.15;
[NSMutableDictionary dictionaryWithDictionary:[self animations]];
[animations setObject:alphaAnimation forKey:@"alphaValue"];
[self setAnimations:animations];
+
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(appIsTerminating)
+ name:NSApplicationWillTerminateNotification
+ object:[NSApplication sharedApplication]];
}
return self;
}
+- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
+}
+
// According to
// http://www.cocoabuilder.com/archive/message/cocoa/2006/6/19/165953,
// NSBorderlessWindowMask windows cannot become key or main. In this
@@ -112,6 +129,21 @@ const NSTimeInterval kOrderOutAnimationDuration = 0.15;
}
}
+// If the app is terminating but the window is still fading out, cancel the
+// animation and close the window to prevent it from leaking.
+// See http://crbug.com/37717
+- (void)appIsTerminating {
+ if (!delayOnClose_)
+ return; // The close has already happened with no Core Animation.
+
+ // Cancel the current animation so that it closes immediately, triggering
+ // |finishCloseAfterAnimation|.
+ [NSAnimationContext beginGrouping];
+ [[NSAnimationContext currentContext] setDuration:kMinimumTimeInterval];
+ [[self animator] setAlphaValue:0.0];
+ [NSAnimationContext endGrouping];
+}
+
// Called by InfoBubbleWindowCloser when the window is to be really closed
// after the fading animation is complete.
- (void)finishCloseAfterAnimation {