Bug 758138 - Current pref value is read before registering the observer. r=ttaubert
authorAmod Narvekar <amod.narvekar@gmail.com>
Thu, 24 Oct 2013 09:54:57 +0200
changeset 152065 9f6f1acf429032ec46e85927fbe89d5e2744d56a
parent 152064 a884fbbc334ae339ac6c9d631a3e8290b4166850
child 152066 00a2a5ad182e602238ceb94fbfc8fa32967a02da
push id25515
push usercbook@mozilla.com
push dateFri, 25 Oct 2013 09:21:40 +0000
treeherdermozilla-central@dff937614268 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs758138
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 758138 - Current pref value is read before registering the observer. r=ttaubert
browser/components/sessionstore/src/SessionStore.jsm
--- a/browser/components/sessionstore/src/SessionStore.jsm
+++ b/browser/components/sessionstore/src/SessionStore.jsm
@@ -516,25 +516,21 @@ let SessionStoreInternal = {
     this._prefBranch = Services.prefs.getBranch("browser.");
 
     gDebuggingEnabled = this._prefBranch.getBoolPref("sessionstore.debug");
 
     Services.prefs.addObserver("browser.sessionstore.debug", () => {
       gDebuggingEnabled = this._prefBranch.getBoolPref("sessionstore.debug");
     }, false);
 
-    XPCOMUtils.defineLazyGetter(this, "_max_tabs_undo", function () {
-      this._prefBranch.addObserver("sessionstore.max_tabs_undo", this, true);
-      return this._prefBranch.getIntPref("sessionstore.max_tabs_undo");
-    });
-
-    XPCOMUtils.defineLazyGetter(this, "_max_windows_undo", function () {
-      this._prefBranch.addObserver("sessionstore.max_windows_undo", this, true);
-      return this._prefBranch.getIntPref("sessionstore.max_windows_undo");
-    });
+    this._max_tabs_undo = this._prefBranch.getIntPref("sessionstore.max_tabs_undo");
+    this._prefBranch.addObserver("sessionstore.max_tabs_undo", this, true);
+
+    this._max_windows_undo = this._prefBranch.getIntPref("sessionstore.max_windows_undo");
+    this._prefBranch.addObserver("sessionstore.max_windows_undo", this, true);
   },
 
   /**
    * Called on application shutdown, after notifications:
    * quit-application-granted, quit-application
    */
   _uninit: function ssi_uninit() {
     if (!this._initialized) {
@@ -1826,17 +1822,17 @@ let SessionStoreInternal = {
 
       // If there's a window already open that we can restore into, use that
       if (canUseWindow) {
         // Since we're not overwriting existing tabs, we want to merge _closedTabs,
         // putting existing ones first. Then make sure we're respecting the max pref.
         if (winState._closedTabs && winState._closedTabs.length) {
           let curWinState = this._windows[windowToUse.__SSi];
           curWinState._closedTabs = curWinState._closedTabs.concat(winState._closedTabs);
-          curWinState._closedTabs.splice(this._prefBranch.getIntPref("sessionstore.max_tabs_undo"), curWinState._closedTabs.length);
+          curWinState._closedTabs.splice(this._max_tabs_undo, curWinState._closedTabs.length);
         }
 
         // Restore into that window - pretend it's a followup since we'll already
         // have a focused window.
         //XXXzpao This is going to merge extData together (taking what was in
         //        winState over what is in the window already. The hack we have
         //        in _preWindowToRestoreInto will prevent most (all?) Panorama
         //        weirdness but we will still merge other extData.