Bug 957436 - [Australis] Follow-up to fix leaks caused by calling uninit() without calling init() before r=bustage
authorTim Taubert <ttaubert@mozilla.com>
Sat, 25 Jan 2014 22:02:18 +0100
changeset 165177 de3521df8d43888f4786fa7757b55ff66362dab0
parent 165176 551290ba9d3b6e750714421c0382908368ea4109
child 165178 3f1dd2a8e972150256f7e7c4ff41e081f3d3d90e
push id26081
push userttaubert@mozilla.com
push dateSun, 26 Jan 2014 03:07:52 +0000
treeherdermozilla-central@3f1dd2a8e972 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs957436
milestone29.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 957436 - [Australis] Follow-up to fix leaks caused by calling uninit() without calling init() before r=bustage
browser/base/content/browser-fxaccounts.js
--- a/browser/base/content/browser-fxaccounts.js
+++ b/browser/base/content/browser-fxaccounts.js
@@ -3,33 +3,47 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function () {
   return Cu.import("resource://gre/modules/FxAccountsCommon.js", {});
 });
 
 let gFxAccounts = {
 
+  _initialized: false,
+
   get topics() {
     delete this.topics;
     return this.topics = [
       FxAccountsCommon.ONVERIFIED_NOTIFICATION
     ];
   },
 
   init: function () {
+    if (this._initialized) {
+      return;
+    }
+
     for (let topic of this.topics) {
       Services.obs.addObserver(this, topic, false);
     }
+
+    this._initialized = true;
   },
 
   uninit: function () {
+    if (!this._initialized) {
+      return;
+    }
+
     for (let topic of this.topics) {
       Services.obs.removeObserver(this, topic);
     }
+
+    this._initialized = false;
   },
 
   observe: function (subject, topic) {
     this.showDoorhanger();
   },
 
   showDoorhanger: function () {
     let panel = document.getElementById("sync-popup");