diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 18:58:22 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 18:58:22 +0000 |
commit | 74f7df7dad8da278eab26e6b323880428b4ea5ce (patch) | |
tree | 3779934be7a1a1d3d3ab2296891c41574ba9fc23 /chrome/browser/gtk | |
parent | 2e65118f139c3c83419776b372a60c90e1405ba6 (diff) | |
download | chromium_src-74f7df7dad8da278eab26e6b323880428b4ea5ce.zip chromium_src-74f7df7dad8da278eab26e6b323880428b4ea5ce.tar.gz chromium_src-74f7df7dad8da278eab26e6b323880428b4ea5ce.tar.bz2 |
[GTK] Don't access a destroyed widget.
BUG=49133
TEST=no DCHECKs when following bug repro steps
Review URL: http://codereview.chromium.org/2878031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52715 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.cc | 20 | ||||
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.h | 5 |
2 files changed, 14 insertions, 11 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index 6f0791b..e7a8ddc 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -176,6 +176,8 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, UpdateNameLabel(); status_label_ = gtk_label_new(NULL); + g_signal_connect(status_label_, "destroy", + G_CALLBACK(gtk_widget_destroyed), &status_label_); // Left align and vertically center the labels. gtk_misc_set_alignment(GTK_MISC(name_label_), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(status_label_), 0, 0.5); @@ -315,6 +317,10 @@ DownloadItemGtk::~DownloadItemGtk() { hbox_.Destroy(); progress_area_.Destroy(); body_.Destroy(); + + // Make sure this widget has been destroyed and the pointer we hold to it + // NULLed. + DCHECK(!status_label_); } void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) { @@ -383,11 +389,10 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) { // Remove the status text label. if (status_text.empty()) { gtk_widget_destroy(status_label_); - status_label_ = NULL; return; } - UpdateStatusLabel(status_label_, status_text_); + UpdateStatusLabel(status_text_); } void DownloadItemGtk::AnimationProgressed(const Animation* animation) { @@ -437,7 +442,7 @@ void DownloadItemGtk::Observe(NotificationType type, } UpdateNameLabel(); - UpdateStatusLabel(status_label_, status_text_); + UpdateStatusLabel(status_text_); UpdateDangerWarning(); } } @@ -521,9 +526,8 @@ void DownloadItemGtk::UpdateNameLabel() { WideToUTF8(elided_filename).c_str()); } -void DownloadItemGtk::UpdateStatusLabel(GtkWidget* status_label, - const std::string& status_text) { - if (!status_label) +void DownloadItemGtk::UpdateStatusLabel(const std::string& status_text) { + if (!status_label_) return; GdkColor text_color; @@ -547,9 +551,9 @@ void DownloadItemGtk::UpdateStatusLabel(GtkWidget* status_label, color_utils::AlphaBlend(blend_color, color, 77)); } - gtk_util::SetLabelColor(status_label, theme_provider_->UseGtkTheme() ? + gtk_util::SetLabelColor(status_label_, theme_provider_->UseGtkTheme() ? NULL : &text_color); - gtk_label_set_text(GTK_LABEL(status_label), status_text.c_str()); + gtk_label_set_text(GTK_LABEL(status_label_), status_text.c_str()); } void DownloadItemGtk::UpdateDangerWarning() { diff --git a/chrome/browser/gtk/download_item_gtk.h b/chrome/browser/gtk/download_item_gtk.h index 4b498b4..a701d99 100644 --- a/chrome/browser/gtk/download_item_gtk.h +++ b/chrome/browser/gtk/download_item_gtk.h @@ -86,9 +86,8 @@ class DownloadItemGtk : public DownloadItem::Observer, // Sets the name label to the correct color. void UpdateNameLabel(); - // Sets the text with the correct color if |status_label| exists. - void UpdateStatusLabel(GtkWidget* status_label, - const std::string& status_text); + // Sets the text of |status_label_| with the correct color. + void UpdateStatusLabel(const std::string& status_text); // Sets the components of the danger warning. void UpdateDangerWarning(); |