diff options
author | paul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-24 19:58:27 +0000 |
---|---|---|
committer | paul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-24 19:58:27 +0000 |
commit | d04182f9e0244738617cc69e9d573008c0e786d2 (patch) | |
tree | b91540c92015a64a6d09983079a9d00b3acb7724 /chrome/browser/cocoa/download_item_cell.mm | |
parent | bc3875bbcc3bde53e875e367eff047554b7b3c34 (diff) | |
download | chromium_src-d04182f9e0244738617cc69e9d573008c0e786d2.zip chromium_src-d04182f9e0244738617cc69e9d573008c0e786d2.tar.gz chromium_src-d04182f9e0244738617cc69e9d573008c0e786d2.tar.bz2 |
Fix a crash when closing a window with a download animation.
This CL fixes a crash that occurs when a small download has
completed quickly, and the download shelf receives two 'complete'
notifications (one at shelf item creation, and one when the
download observer fires).
We detect this case by checking for an existing complete
animation and ignoring the second notification.
BUG=18416 (http://crbug.com/18416)
TEST=Download something, close the window before the animation completes
and notice that Chrome doesn't crash.
Review URL: http://codereview.chromium.org/174326
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24131 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/download_item_cell.mm')
-rw-r--r-- | chrome/browser/cocoa/download_item_cell.mm | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/download_item_cell.mm b/chrome/browser/cocoa/download_item_cell.mm index 81e25d1..7c82b2b 100644 --- a/chrome/browser/cocoa/download_item_cell.mm +++ b/chrome/browser/cocoa/download_item_cell.mm @@ -122,6 +122,10 @@ const int kCompleteAnimationDuration = 2.5; - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + if ([completionAnimation_ isAnimating]) + [completionAnimation_ stopAnimation]; + if ([hideStatusAnimation_ isAnimating]) + [hideStatusAnimation_ stopAnimation]; [secondaryTitle_ release]; [secondaryFont_ release]; [super dealloc]; @@ -145,6 +149,12 @@ const int kCompleteAnimationDuration = 2.5; switch (downloadModel->download()->state()) { case DownloadItem::COMPLETE: + // Small downloads may start in a complete state due to asynchronous + // notifications. In this case, we'll get a second complete notification + // via the observers, so we ignore it and avoid creating a second complete + // animation. + if (completionAnimation_.get()) + break; completionAnimation_.reset([[DownloadItemCellAnimation alloc] initWithDownloadItemCell:self duration:kCompleteAnimationDuration |