diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index 3bff65ab6e7..23479abab94 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -1067,30 +1067,24 @@ var PlacesStarButton = { // after closing the toolbar customization dialog. let PlacesToolbarHelper = { _place: "place:folder=TOOLBAR", - _cachedElt: null, - onBrowserWindowClose: function PTH_onBrowserWindowClose() { - if (this._cachedElt) - this._cachedElt._placesView.uninit(); + get _viewElt() { + return document.getElementById("PlacesToolbar"); }, - updateState: function PTH_updateState() { - let currentElt = document.getElementById("PlacesToolbar"); - - // Bail out if the state has not changed. - if (currentElt == this._cachedElt) - return; - - if (!this._cachedElt) { - // The toolbar has been added. + init: function PTH_init() { + if (this._viewElt) new PlacesToolbar(this._place); - this._cachedElt = currentElt; - } - else { - // The toolbar has been removed. - this._cachedElt._placesView.uninit(); - this._cachedElt = null; - } + }, + + customizeStart: function PTH_customizeStart() { + let viewElt = this._viewElt; + if (viewElt && viewElt._placesView) + viewElt._placesView.uninit(); + }, + + customizeDone: function PTH_customizeDone() { + this.init(); } }; diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 8d457756128..7f4aa064336 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1419,7 +1419,7 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) { dump("nsSessionStore could not be initialized: " + ex + "\n"); } - PlacesToolbarHelper.updateState(); + PlacesToolbarHelper.init(); // bookmark-all-tabs command gBookmarkAllTabsHandler.init(); @@ -3420,6 +3420,7 @@ function BrowserCustomizeToolbar() CombinedStopReload.uninit(); + PlacesToolbarHelper.customizeStart(); BookmarksMenuButton.customizeStart(); var customizeURL = "chrome://global/content/customizeToolbar.xul"; @@ -3483,7 +3484,7 @@ function BrowserToolboxCustomizeDone(aToolboxChanged) { #endif } - PlacesToolbarHelper.updateState(); + PlacesToolbarHelper.customizeDone(); BookmarksMenuButton.customizeDone(); UpdateUrlbarSearchSplitterState();