From 421dd05db9092a15df1a2c5c1011c588148078db Mon Sep 17 00:00:00 2001 From: "shess@chromium.org" Date: Mon, 21 Jun 2010 21:02:32 +0000 Subject: [Mac] Tracking-area hygiene. When tracking areas have an owner different from the view they are added to, they can exist past the owner's death. These have not been implicated in any crashes, but it's the best idea I have for the bug. BUG=38441 TEST=none Review URL: http://codereview.chromium.org/2823013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50387 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/chrome_browser_window.mm | 4 ++++ chrome/browser/cocoa/download_item_cell.mm | 8 ++++++++ chrome/browser/cocoa/fullscreen_controller.mm | 1 + chrome/browser/cocoa/gradient_button_cell.mm | 9 +++++++++ 4 files changed, 22 insertions(+) (limited to 'chrome/browser/cocoa') diff --git a/chrome/browser/cocoa/chrome_browser_window.mm b/chrome/browser/cocoa/chrome_browser_window.mm index eecf09f..35aae1a 100644 --- a/chrome/browser/cocoa/chrome_browser_window.mm +++ b/chrome/browser/cocoa/chrome_browser_window.mm @@ -58,6 +58,10 @@ namespace { - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSDistributedNotificationCenter defaultCenter] removeObserver:self]; + if (widgetTrackingArea_) { + [[self frameView] removeTrackingArea:widgetTrackingArea_]; + widgetTrackingArea_.reset(); + } [super dealloc]; } diff --git a/chrome/browser/cocoa/download_item_cell.mm b/chrome/browser/cocoa/download_item_cell.mm index 84d4421..6e14a27 100644 --- a/chrome/browser/cocoa/download_item_cell.mm +++ b/chrome/browser/cocoa/download_item_cell.mm @@ -219,6 +219,14 @@ NSGradient* BackgroundTheme::GetNSGradient(int id) const { [completionAnimation_ stopAnimation]; if ([hideStatusAnimation_ isAnimating]) [hideStatusAnimation_ stopAnimation]; + if (trackingAreaButton_) { + [[self controlView] removeTrackingArea:trackingAreaButton_]; + trackingAreaButton_.reset(); + } + if (trackingAreaDropdown_) { + [[self controlView] removeTrackingArea:trackingAreaDropdown_]; + trackingAreaDropdown_.reset(); + } [secondaryTitle_ release]; [secondaryFont_ release]; [super dealloc]; diff --git a/chrome/browser/cocoa/fullscreen_controller.mm b/chrome/browser/cocoa/fullscreen_controller.mm index 74de909..1b463d0 100644 --- a/chrome/browser/cocoa/fullscreen_controller.mm +++ b/chrome/browser/cocoa/fullscreen_controller.mm @@ -169,6 +169,7 @@ const CGFloat kFloatingBarVerticalOffset = 22; - (void)dealloc { DCHECK(!isFullscreen_); + DCHECK(!trackingArea_); [super dealloc]; } diff --git a/chrome/browser/cocoa/gradient_button_cell.mm b/chrome/browser/cocoa/gradient_button_cell.mm index 15110e8..523b4d7 100644 --- a/chrome/browser/cocoa/gradient_button_cell.mm +++ b/chrome/browser/cocoa/gradient_button_cell.mm @@ -88,6 +88,14 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; return self; } +- (void)dealloc { + if (trackingArea_) { + [[self controlView] removeTrackingArea:trackingArea_]; + trackingArea_.reset(); + } + [super dealloc]; +} + - (NSGradient*)gradientForHoverAlpha:(CGFloat)hoverAlpha isThemed:(BOOL)themed { CGFloat startAlpha = 0.6 + 0.3 * hoverAlpha; @@ -146,6 +154,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; if (showOnly) { if (trackingArea_.get()) { [self setShowsBorderOnlyWhileMouseInside:NO]; + [[self controlView] removeTrackingArea:trackingArea_]; } trackingArea_.reset([[NSTrackingArea alloc] initWithRect:[[self controlView] -- cgit v1.1