From b1746c5217500c721519d345d8a6d8468ec6e7b3 Mon Sep 17 00:00:00 2001 From: Dietrich Ayala Date: Wed, 14 Oct 2009 17:01:55 -0700 Subject: [PATCH] backing out bug 506471 due to leaks --- .../components/exthelper/extApplication.js | 38 +++++++------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/toolkit/components/exthelper/extApplication.js b/toolkit/components/exthelper/extApplication.js index 3c6b5e553ed4..5df8d4e76cf8 100644 --- a/toolkit/components/exthelper/extApplication.js +++ b/toolkit/components/exthelper/extApplication.js @@ -103,9 +103,8 @@ EventItem.prototype = { //================================================= // Events constructor -function Events(notifier) { +function Events() { this._listeners = []; - this._notifier = notifier; } //================================================= @@ -120,10 +119,6 @@ Events.prototype = { listener: aListener }); - if (this._notifier) { - this._notifier(aEvent, aListener); - } - function hasFilter(element) { return element.event == aEvent && element.listener == aListener; } @@ -570,14 +565,23 @@ extApplication.prototype = { this._prefs = null; this._extensions = null; this._events = null; - this._registered = {}; this._info = Components.classes["@mozilla.org/xre/app-info;1"] .getService(Ci.nsIXULAppInfo); + + var os = Components.classes["@mozilla.org/observer-service;1"] + .getService(Ci.nsIObserverService); + + os.addObserver(this, "final-ui-startup", false); + os.addObserver(this, "quit-application-requested", false); + os.addObserver(this, "xpcom-shutdown", false); }, // get this contractID registered for certain categories via XPCOMUtils _xpcom_categories: [ + // make Application a startup observer + { category: "app-startup", service: true }, + // add Application as a global property for easy access { category: "JavaScript global privileged property" } ], @@ -635,7 +639,6 @@ extApplication.prototype = { var os = Components.classes["@mozilla.org/observer-service;1"] .getService(Ci.nsIObserverService); - os.removeObserver(this, "app-startup"); os.removeObserver(this, "final-ui-startup"); os.removeObserver(this, "quit-application-requested"); os.removeObserver(this, "xpcom-shutdown"); @@ -678,23 +681,8 @@ extApplication.prototype = { }, get events() { - if (this._events == null) { - var self = this; - function registerCheck(ev, k) { - var rmap = { "load": "app-startup", - "ready": "final-ui-startup", - "quit": "quit-application-requested", - "unload": "xpcom-shutdown" }; - if (!(ev in rmap) || ev in self._registered) - return; - - Components.classes["@mozilla.org/observer-service;1"] - .getService(Ci.nsIObserverService).addObserver(self, rmap[ev]); - self._registered[ev] = true; - } - - this._events = new Events(registerCheck); - } + if (this._events == null) + this._events = new Events(); return this._events; },