diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 01:57:47 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 01:57:47 +0000 |
commit | 8a0b3b0ed44bf64d38fd1065a1fa3dcf9f44d729 (patch) | |
tree | a8ca83637e50d9fdbea3780d86d24725f4fd8f1d /chrome | |
parent | 2fca3cd369dc0847cc4fbf9bdd65428c640f8669 (diff) | |
download | chromium_src-8a0b3b0ed44bf64d38fd1065a1fa3dcf9f44d729.zip chromium_src-8a0b3b0ed44bf64d38fd1065a1fa3dcf9f44d729.tar.gz chromium_src-8a0b3b0ed44bf64d38fd1065a1fa3dcf9f44d729.tar.bz2 |
gtk - Prevent crash on shutdown when animating status bubble and download item
BUG=68888
TEST=none
Review URL: http://codereview.chromium.org/6610010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76860 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/ui/gtk/download_item_gtk.cc | 25 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/download_item_gtk.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/status_bubble_gtk.cc | 20 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/status_bubble_gtk.h | 2 |
4 files changed, 26 insertions, 23 deletions
diff --git a/chrome/browser/ui/gtk/download_item_gtk.cc b/chrome/browser/ui/gtk/download_item_gtk.cc index 15f15fd..167a020 100644 --- a/chrome/browser/ui/gtk/download_item_gtk.cc +++ b/chrome/browser/ui/gtk/download_item_gtk.cc @@ -256,26 +256,26 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, gtk_widget_hide(menu_button_); // Create an hbox to hold it all. - dangerous_hbox_ = gtk_hbox_new(FALSE, kDangerousElementPadding); + dangerous_hbox_.Own(gtk_hbox_new(FALSE, kDangerousElementPadding)); // Add padding at the beginning and end. The hbox will add padding between // the empty labels and the other elements. GtkWidget* empty_label_a = gtk_label_new(NULL); GtkWidget* empty_label_b = gtk_label_new(NULL); - gtk_box_pack_start(GTK_BOX(dangerous_hbox_), empty_label_a, + gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), empty_label_a, FALSE, FALSE, 0); - gtk_box_pack_end(GTK_BOX(dangerous_hbox_), empty_label_b, + gtk_box_pack_end(GTK_BOX(dangerous_hbox_.get()), empty_label_b, FALSE, FALSE, 0); // Create the warning icon. dangerous_image_ = gtk_image_new(); - gtk_box_pack_start(GTK_BOX(dangerous_hbox_), dangerous_image_, + gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), dangerous_image_, FALSE, FALSE, 0); dangerous_label_ = gtk_label_new(NULL); // We pass TRUE, TRUE so that the label will condense to less than its // request when the animation is going on. - gtk_box_pack_start(GTK_BOX(dangerous_hbox_), dangerous_label_, + gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), dangerous_label_, TRUE, TRUE, 0); // Create the nevermind button. @@ -283,7 +283,8 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, l10n_util::GetStringUTF8(IDS_DISCARD_DOWNLOAD).c_str()); g_signal_connect(dangerous_decline, "clicked", G_CALLBACK(OnDangerousDeclineThunk), this); - gtk_util::CenterWidgetInHBox(dangerous_hbox_, dangerous_decline, false, 0); + gtk_util::CenterWidgetInHBox(dangerous_hbox_.get(), dangerous_decline, + false, 0); // Create the ok button. GtkWidget* dangerous_accept = gtk_button_new_with_label( @@ -292,14 +293,15 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, IDS_CONTINUE_EXTENSION_DOWNLOAD : IDS_SAVE_DOWNLOAD).c_str()); g_signal_connect(dangerous_accept, "clicked", G_CALLBACK(OnDangerousAcceptThunk), this); - gtk_util::CenterWidgetInHBox(dangerous_hbox_, dangerous_accept, false, 0); + gtk_util::CenterWidgetInHBox(dangerous_hbox_.get(), dangerous_accept, false, + 0); // Put it in an alignment so that padding will be added on the left and // right. dangerous_prompt_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); gtk_alignment_set_padding(GTK_ALIGNMENT(dangerous_prompt_), 0, 0, kDangerousElementPadding, kDangerousElementPadding); - gtk_container_add(GTK_CONTAINER(dangerous_prompt_), dangerous_hbox_); + gtk_container_add(GTK_CONTAINER(dangerous_prompt_), dangerous_hbox_.get()); gtk_box_pack_start(GTK_BOX(hbox_.get()), dangerous_prompt_, FALSE, FALSE, 0); gtk_widget_set_app_paintable(dangerous_prompt_, TRUE); @@ -315,7 +317,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, // Set the initial width of the widget to be animated. if (IsDangerous()) { - gtk_widget_set_size_request(dangerous_hbox_, + gtk_widget_set_size_request(dangerous_hbox_.get(), dangerous_hbox_start_width_, -1); } else { gtk_widget_set_size_request(body_.get(), kMinDownloadItemWidth, -1); @@ -335,6 +337,7 @@ DownloadItemGtk::~DownloadItemGtk() { hbox_.Destroy(); progress_area_.Destroy(); body_.Destroy(); + dangerous_hbox_.Destroy(); // Make sure this widget has been destroyed and the pointer we hold to it // NULLed. @@ -421,7 +424,7 @@ void DownloadItemGtk::AnimationProgressed(const ui::Animation* animation) { dangerous_hbox_start_width_) * new_item_animation_->GetCurrentValue()); int showing_width = dangerous_hbox_start_width_ + progress; - gtk_widget_set_size_request(dangerous_hbox_, showing_width, -1); + gtk_widget_set_size_request(dangerous_hbox_.get(), showing_width, -1); } else { DCHECK(animation == new_item_animation_.get()); int showing_width = std::max(kMinDownloadItemWidth, @@ -630,7 +633,7 @@ void DownloadItemGtk::UpdateDangerWarning() { // The width will depend on the text. We must do this each time we possibly // change the label above. - gtk_widget_size_request(dangerous_hbox_, &req); + gtk_widget_size_request(dangerous_hbox_.get(), &req); dangerous_hbox_full_width_ = req.width; dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - label_width; } diff --git a/chrome/browser/ui/gtk/download_item_gtk.h b/chrome/browser/ui/gtk/download_item_gtk.h index e2f2583..fd3b8d1c 100644 --- a/chrome/browser/ui/gtk/download_item_gtk.h +++ b/chrome/browser/ui/gtk/download_item_gtk.h @@ -194,7 +194,7 @@ class DownloadItemGtk : public DownloadItem::Observer, GtkWidget* dangerous_label_; // An hbox for holding components of the dangerous download dialog. - GtkWidget* dangerous_hbox_; + OwnedWidgetGtk dangerous_hbox_; int dangerous_hbox_start_width_; int dangerous_hbox_full_width_; diff --git a/chrome/browser/ui/gtk/status_bubble_gtk.cc b/chrome/browser/ui/gtk/status_bubble_gtk.cc index 7f2dccb..b8a3980 100644 --- a/chrome/browser/ui/gtk/status_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/status_bubble_gtk.cc @@ -40,7 +40,6 @@ const int kMousePadding = 20; StatusBubbleGtk::StatusBubbleGtk(Profile* profile) : theme_provider_(GtkThemeProvider::GetFrom(profile)), padding_(NULL), - label_(NULL), flip_horizontally_(false), y_offset_(0), download_shelf_is_visible_(false), @@ -55,6 +54,7 @@ StatusBubbleGtk::StatusBubbleGtk(Profile* profile) } StatusBubbleGtk::~StatusBubbleGtk() { + label_.Destroy(); container_.Destroy(); } @@ -134,9 +134,9 @@ void StatusBubbleGtk::SetStatusTextTo(const std::string& status_utf8) { hide_timer_.Start(base::TimeDelta::FromMilliseconds(kHideDelay), this, &StatusBubbleGtk::Hide); } else { - gtk_label_set_text(GTK_LABEL(label_), status_utf8.c_str()); + gtk_label_set_text(GTK_LABEL(label_.get()), status_utf8.c_str()); GtkRequisition req; - gtk_widget_size_request(label_, &req); + gtk_widget_size_request(label_.get(), &req); desired_width_ = req.width; UpdateLabelSizeRequest(); @@ -245,14 +245,14 @@ void StatusBubbleGtk::Observe(NotificationType type, void StatusBubbleGtk::InitWidgets() { bool ltr = !base::i18n::IsRTL(); - label_ = gtk_label_new(NULL); + label_.Own(gtk_label_new(NULL)); padding_ = gtk_alignment_new(0, 0, 1, 1); gtk_alignment_set_padding(GTK_ALIGNMENT(padding_), kInternalTopBottomPadding, kInternalTopBottomPadding, kInternalLeftRightPadding + (ltr ? 0 : kCornerSize), kInternalLeftRightPadding + (ltr ? kCornerSize : 0)); - gtk_container_add(GTK_CONTAINER(padding_), label_); + gtk_container_add(GTK_CONTAINER(padding_), label_.get()); gtk_widget_show_all(padding_); container_.Own(gtk_event_box_new()); @@ -279,7 +279,7 @@ void StatusBubbleGtk::InitWidgets() { void StatusBubbleGtk::UserChangedTheme() { if (theme_provider_->UseGtkTheme()) { - gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, NULL); + gtk_widget_modify_fg(label_.get(), GTK_STATE_NORMAL, NULL); gtk_widget_modify_bg(container_.get(), GTK_STATE_NORMAL, NULL); } else { // TODO(erg): This is the closest to "text that will look good on a @@ -287,7 +287,7 @@ void StatusBubbleGtk::UserChangedTheme() { // there will be a better color to pick. GdkColor bookmark_text = theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); - gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, &bookmark_text); + gtk_widget_modify_fg(label_.get(), GTK_STATE_NORMAL, &bookmark_text); GdkColor toolbar_color = theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR); @@ -324,7 +324,7 @@ void StatusBubbleGtk::SetFlipHorizontally(bool flip_horizontally) { } void StatusBubbleGtk::ExpandURL() { - start_width_ = label_->allocation.width; + start_width_ = label_.get()->allocation.width; expand_animation_.reset(new ui::SlideAnimation(this)); expand_animation_->SetTweenType(ui::Tween::LINEAR); expand_animation_->Show(); @@ -334,13 +334,13 @@ void StatusBubbleGtk::ExpandURL() { void StatusBubbleGtk::UpdateLabelSizeRequest() { if (!expanded() || !expand_animation_->is_animating()) { - gtk_widget_set_size_request(label_, -1, -1); + gtk_widget_set_size_request(label_.get(), -1, -1); return; } int new_width = start_width_ + (desired_width_ - start_width_) * expand_animation_->GetCurrentValue(); - gtk_widget_set_size_request(label_, new_width, -1); + gtk_widget_set_size_request(label_.get(), new_width, -1); } // See http://crbug.com/68897 for why we have to handle this event. diff --git a/chrome/browser/ui/gtk/status_bubble_gtk.h b/chrome/browser/ui/gtk/status_bubble_gtk.h index 0608f7a..0ccc23c 100644 --- a/chrome/browser/ui/gtk/status_bubble_gtk.h +++ b/chrome/browser/ui/gtk/status_bubble_gtk.h @@ -123,7 +123,7 @@ class StatusBubbleGtk : public StatusBubble, GtkWidget* padding_; // The GtkLabel holding the text. - GtkWidget* label_; + OwnedWidgetGtk label_; // The status text we want to display when there are no URLs to display. std::string status_text_; |