Index: chrome/browser/views/download_item_view.cc |
=================================================================== |
--- chrome/browser/views/download_item_view.cc (revision 55436) |
+++ chrome/browser/views/download_item_view.cc (working copy) |
@@ -132,7 +132,8 @@ |
dangerous_download_label_sized_(false), |
disabled_while_opening_(false), |
creation_time_(base::Time::Now()), |
- ALLOW_THIS_IN_INITIALIZER_LIST(reenable_method_factory_(this)) { |
+ ALLOW_THIS_IN_INITIALIZER_LIST(reenable_method_factory_(this)), |
+ deleted_(NULL) { |
DCHECK(download_); |
download_->AddObserver(this); |
@@ -311,6 +312,8 @@ |
icon_consumer_.CancelAllRequests(); |
StopDownloadProgress(); |
download_->RemoveObserver(this); |
+ if (deleted_) |
+ *deleted_ = true; |
} |
// Progress animation handlers. |
@@ -819,7 +822,14 @@ |
if (!context_menu_.get()) |
context_menu_.reset(new DownloadShelfContextMenuWin(model_.get())); |
+ // When we call the Run method on the menu, it runs an inner message loop |
+ // that might causes us to be deleted. |
+ bool deleted = false; |
+ deleted_ = &deleted; |
context_menu_->Run(point); |
+ if (deleted) |
+ return true; // We have been deleted! Don't access 'this'. |
+ deleted_ = NULL; |
// If the menu action was to remove the download, this view will also be |
// invalid so we must not access 'this' in this case. |