Replaced the observer removal code in the nsExtensionManager component. The Observers helper class was not removing them correctly. client-1.6 client-release-1.6rc5
authorJose E. Bolanos <jose@appcoast.com>
Wed, 18 Aug 2010 18:00:36 -0600
branchclient-1.6
changeset 1337 38a37f6647d2524017904070ddbda3ea849d7616
parent 1335 7b517aab28efa08beedd961667c8cda64bfc5438
child 1338 1e560f4efc5278a8a087f4a8bc04d177af99f797
push id859
push userjose@glaxstar.com
push dateThu, 19 Aug 2010 00:05:21 +0000
Replaced the observer removal code in the nsExtensionManager component. The Observers helper class was not removing them correctly.
client/components/nsPersonasExtensionManager.js
--- a/client/components/nsPersonasExtensionManager.js
+++ b/client/components/nsPersonasExtensionManager.js
@@ -57,16 +57,17 @@ const URI_EXTENSION_MANAGER           = 
 const FEATURES_EXTENSION_MANAGER      = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
 const PREFIX_NS_EM                    = "http://www.mozilla.org/2004/em-rdf#";
 const PREFIX_ITEM_URI                 = "urn:mozilla:item:";
 
 // ID of the original Extension Manager, "@mozilla.org/extensions/manager;1"
 var EXTENSIONS_MANAGER_ID = "{8A115FAA-7DCB-4e8f-979B-5F53472F51CF}";
 var gOldHandler = null;
 var gRDF = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
+var gOS = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
 
 const DEFAULT_THEME = "classic/1.0";
 
 //
 // Utility Functions
 //
 
 function stringData(literalOrResource) {
@@ -152,19 +153,23 @@ PersonasExtensionManager.prototype = {
     // properties of the requested interface only.
     delete gOldHandler;
     gOldHandler =
       Components.classesByID[EXTENSIONS_MANAGER_ID].
         getService(Ci.nsIExtensionManager);
     gOldHandler.QueryInterface(aIID);
 
     // Remove the original nsExtensionManager listeners for the
-    // lightweight theme topics.
-    Observers.remove("lightweight-theme-preview-requested", gOldHandler);
-    Observers.remove("lightweight-theme-change-requested", gOldHandler);
+    // lightweight theme topics. This might fail when the given aIID has not
+    // these topics registered, but can be safely ignored.
+    try {
+      gOS.removeObserver(gOldHandler, "lightweight-theme-preview-requested");
+      gOS.removeObserver(gOldHandler, "lightweight-theme-change-requested");
+    }
+    catch (e) {}
 
     inheritCurrentInterface(this, gOldHandler);
     return this;
   },
 
   /* Whether the current theme is compatible with Personas */
   _currentThemeSkinnable : true,