Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: chrome/browser/views/download_item_view.cc

Issue 3052043: Fix crasher with download bar. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Nulling deleted_ Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/download_item_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/download_item_view.cc
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index d7d865b391cc4f2b6ff5c5fcb167ba176458986c..70ae46ed049578127dac51d58099bc6647abe919 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -127,7 +127,8 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
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);
@@ -306,6 +307,8 @@ DownloadItemView::~DownloadItemView() {
icon_consumer_.CancelAllRequests();
StopDownloadProgress();
download_->RemoveObserver(this);
+ if (deleted_)
+ *deleted_ = true;
}
// Progress animation handlers.
@@ -814,7 +817,14 @@ bool DownloadItemView::OnMousePressed(const views::MouseEvent& event) {
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.
« no previous file with comments | « chrome/browser/views/download_item_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698