diff --git a/toolkit/mozapps/extensions/src/nsBlocklistService.js b/toolkit/mozapps/extensions/src/nsBlocklistService.js index 431e8eb887a..68d7dcb2d24 100644 --- a/toolkit/mozapps/extensions/src/nsBlocklistService.js +++ b/toolkit/mozapps/extensions/src/nsBlocklistService.js @@ -83,7 +83,8 @@ var gLoggingEnabled = null; function LOG(string) { if (gLoggingEnabled) { dump("*** " + string + "\n"); - gConsole.logStringMessage(string); + if (gConsole) + gConsole.logStringMessage(string); } } @@ -223,6 +224,7 @@ Blocklist.prototype = { case "app-startup": gOS.addObserver(this, "plugins-list-updated", false); gOS.addObserver(this, "profile-after-change", false); + gOS.addObserver(this, "quit-application", false); break; case "profile-after-change": gLoggingEnabled = getPref("getBoolPref", PREF_EM_LOGGING_ENABLED, false); @@ -234,10 +236,12 @@ Blocklist.prototype = { case "plugins-list-updated": this._checkPluginsList(); break; + case "quit-application": + gOS.removeObserver(this, "plugins-list-updated"); + gOS.removeObserver(this, "profile-after-change"); + gOS.removeObserver(this, "quit-application"); case "xpcom-shutdown": gOS.removeObserver(this, "xpcom-shutdown"); - gOS.removeObserver(this, "profile-after-change"); - gOS.removeObserver(this, "plugins-list-updated"); gOS = null; gPref = null; gConsole = null; diff --git a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in index 023a036e73d..eb56a743441 100644 --- a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in +++ b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in @@ -533,7 +533,8 @@ function removeDirRecursive(dir) { function LOG(string) { if (gLoggingEnabled) { dump("*** " + string + "\n"); - gConsole.logStringMessage(string); + if (gConsole) + gConsole.logStringMessage(string); } } @@ -2409,6 +2410,7 @@ ExtensionManager.prototype = { switch (topic) { case "app-startup": gOS.addObserver(this, "profile-after-change", false); + gOS.addObserver(this, "quit-application", false); break; case "profile-after-change": this._profileSelected(); @@ -2419,6 +2421,9 @@ ExtensionManager.prototype = { case "offline-requested": this._confirmCancelDownloadsOnOffline(subject); break; + case "quit-application": + gOS.removeObserver(this, "profile-after-change"); + gOS.removeObserver(this, "quit-application"); case "xpcom-shutdown": this._shutdown(); break; @@ -2532,7 +2537,6 @@ ExtensionManager.prototype = { */ _shutdown: function() { gOS.removeObserver(this, "xpcom-shutdown"); - gOS.removeObserver(this, "profile-after-change"); // Release strongly held services. gOS = null;