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 165175 de3521df8d43888f4786fa7757b55ff66362dab0
parent 165174 551290ba9d3b6e750714421c0382908368ea4109
child 165178 3f1dd2a8e972150256f7e7c4ff41e081f3d3d90e
push id4575
push userttaubert@mozilla.com
push dateSat, 25 Jan 2014 21:06:53 +0000
treeherderfx-team@de3521df8d43 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs957436
milestone29.0a1
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");