summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 02:07:11 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 02:07:11 +0000
commit1976d41ac728fcceb30f2df3c243cb7417f538f1 (patch)
treebd38a26766be79edf047b729564acada01ac214f
parent3068566587d45eab5e6ffcb4ec737fe4838b9e13 (diff)
downloadchromium_src-1976d41ac728fcceb30f2df3c243cb7417f538f1.zip
chromium_src-1976d41ac728fcceb30f2df3c243cb7417f538f1.tar.gz
chromium_src-1976d41ac728fcceb30f2df3c243cb7417f538f1.tar.bz2
GTK: avoid a hang brought on by an infinite size-allocate queue.
This is not the most satisfying fix imaginable. I'm not sure why we are getting size-allocate events where the visibility of the chevron has changed but our allocation is not yet updated. In principle I suppose it would be better not to call any function that might cause an allocation from within a size-allocate handler, but guaranteeing that is probably pretty hard. BUG=24470 TEST=repro steps no longer repro; also, verified that the early return line is actually being hit. Review URL: http://codereview.chromium.org/270078 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28778 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc16
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.h4
2 files changed, 17 insertions, 3 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index 9bcbb80..3387013 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -125,7 +125,8 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window,
theme_provider_(GtkThemeProvider::GetFrom(profile)),
show_instructions_(true),
menu_bar_helper_(this),
- floating_(false) {
+ floating_(false),
+ last_allocation_width_(-1) {
Init(profile);
SetProfile(profile);
// Force an update by simulating being in the wrong state.
@@ -464,11 +465,10 @@ void BookmarkBarGtk::SetInstructionState() {
}
void BookmarkBarGtk::SetChevronState() {
- if (!GTK_WIDGET_VISIBLE(bookmark_toolbar_.get()))
+ if (!GTK_WIDGET_VISIBLE(bookmark_hbox_))
return;
int extra_space = 0;
-
if (GTK_WIDGET_VISIBLE(overflow_button_))
extra_space = overflow_button_->allocation.width;
@@ -937,6 +937,16 @@ void BookmarkBarGtk::OnToolbarDragLeave(GtkToolbar* toolbar,
void BookmarkBarGtk::OnToolbarSizeAllocate(GtkWidget* widget,
GtkAllocation* allocation,
BookmarkBarGtk* bar) {
+ if (bar->bookmark_toolbar_.get()->allocation.width ==
+ bar->last_allocation_width_) {
+ // If the width hasn't changed, then the visibility of the chevron
+ // doesn't need to change. This check prevents us from getting stuck in a
+ // loop where allocates are queued indefinitely while the visibility of
+ // overflow chevron toggles without actual resizes of the toolbar.
+ return;
+ }
+ bar->last_allocation_width_ = bar->bookmark_toolbar_.get()->allocation.width;
+
bar->SetChevronState();
}
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.h b/chrome/browser/gtk/bookmark_bar_gtk.h
index 702bee2..1cb4cb9 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.h
+++ b/chrome/browser/gtk/bookmark_bar_gtk.h
@@ -315,6 +315,10 @@ class BookmarkBarGtk : public AnimationDelegate,
// what ShouldShowFloating() returns.
bool floating_;
+ // Used to optimize out |bookmark_toolbar_| size-allocate events we don't
+ // need to respond to.
+ int last_allocation_width_;
+
NotificationRegistrar registrar_;
};