From d57d13a6fbea0fc868f8a334857e228989cfbfdf Mon Sep 17 00:00:00 2001 From: "finnur@chromium.org" Date: Sun, 10 Oct 2010 09:14:48 +0000 Subject: The test exposed similar problems on Linux and Mac as I fixed on Windows. The test was failing because we get a call to UpdatePageActions while we are in the process of creating PageActions, which leads to an infinite loop (create vector, add page action, update page actions, delete vector, create vector, ...). BUG=58141 TEST=ExtensionApiTest.TestCrash57333 Review URL: http://codereview.chromium.org/3632001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62111 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/location_bar/page_action_decoration.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'chrome/browser/cocoa/location_bar') diff --git a/chrome/browser/cocoa/location_bar/page_action_decoration.mm b/chrome/browser/cocoa/location_bar/page_action_decoration.mm index 337cd2f..572a65a 100644 --- a/chrome/browser/cocoa/location_bar/page_action_decoration.mm +++ b/chrome/browser/cocoa/location_bar/page_action_decoration.mm @@ -32,7 +32,7 @@ PageActionDecoration::PageActionDecoration( LocationBarViewMac* owner, Profile* profile, ExtensionAction* page_action) - : owner_(owner), + : owner_(NULL), profile_(profile), page_action_(page_action), tracker_(this), @@ -59,6 +59,10 @@ PageActionDecoration::PageActionDecoration( registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, Source(profile_)); + + // We set the owner last of all so that we can determine whether we are in + // the process of initializing this class or not. + owner_ = owner; } PageActionDecoration::~PageActionDecoration() {} @@ -118,7 +122,11 @@ void PageActionDecoration::OnImageLoaded( page_action_icons_[page_action_->default_icon_path()] = *image; } - owner_->UpdatePageActions(); + // If we have no owner, that means this class is still being constructed and + // we should not UpdatePageActions, since it leads to the PageActions being + // destroyed again and new ones recreated (causing an infinite loop). + if (owner_) + owner_->UpdatePageActions(); } void PageActionDecoration::UpdateVisibility(TabContents* contents, -- cgit v1.1